| Copyright | (C) 2026 - Eitan Chatav |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | Eitan Chatav <eitan.chatav@gmail.com> |
| Stability | provisional |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.Profunctor.Filtrator
Contents
Description
Filtrator
class (Cochoice p, forall x. Filterable (p x)) => Filtrator (p :: Type -> Type -> Type) where Source #
The Filtrator class extends Cochoice,
as well as Filterable, adding the filtrate method,
which projects a profunctor of sums onto its summands.
For a CocartesianChoice,
filtrate is a retraction of alternate,
projecting a summand back out of its injection,
prop> fst (filtrate (alternate (Left p))) = p prop> snd (filtrate (alternate (Right p))) = p
that is, since unleft is fst . filtrate & left' is alternate . Left,
prop> unleft . left' = id prop> unright . right' = id
filtrate isn't a retraction of
>+< in general, though,
since it tries its summands in turn, & the second summand
of a left-biased or predictive one,
like the Parsor s Maybe or Parsector parsers of distributors-grammar,
is lost where the first applies. Nor is >+<
a retraction of filtrate, since a profunctor of sums may cross summands,
as rmap (either Right Left) does.
Minimal complete definition
Nothing
Methods
filtrate :: p (Either a c) (Either b d) -> (p a b, p c d) Source #
prop> unleft = fst . filtrate prop> unleft = lmap Left . mapMaybe (either Just (const Nothing)) prop> unright = snd . filtrate prop> unright = lmap Right . mapMaybe (either (const Nothing) Just)
filtrate is a distant relative to partitionEithers.
filtrate can be given a default value for Monadic
Alternators via mfiltrate.
prop> filtrate = mfiltrate
filtrate has a default for Choice & Cochoice partial profunctors.
Instances
| Filtrator p => Filtrator (Coyoneda p) Source # | |
| Filtrator p => Filtrator (Yoneda p) Source # | |
| Filtrator (Binocular a b) Source # | |
| Filtrator (Spectacle a b) Source # | |
| Filtrator (PartialMarket a b) Source # | |
Defined in Data.Profunctor.Filtrator Methods filtrate :: PartialMarket a b (Either a0 c) (Either b0 d) -> (PartialMarket a b a0 b0, PartialMarket a b c d) Source # | |
| (Profunctor p, forall x. Functor (p x), Filterable f) => Filtrator (WrappedPafb f p) Source # | |
Defined in Data.Profunctor.Filtrator Methods filtrate :: WrappedPafb f p (Either a c) (Either b d) -> (WrappedPafb f p a b, WrappedPafb f p c d) Source # | |
| Filtrator (Forget r :: Type -> Type -> Type) Source # | |
| Filterable f => Filtrator (Joker f :: Type -> Type -> Type) Source # | |
| Monad m => Filtrator (Varifocus a b m) Source # | |