distributors-0.6.0.0: Unifying Parsers, Printers & Grammars
Copyright(C) 2026 - Eitan Chatav
LicenseBSD-style (see the file LICENSE)
MaintainerEitan Chatav <eitan.chatav@gmail.com>
Stabilityprovisional
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Profunctor.Filtrator

Contents

Description

 
Synopsis

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 is an oplax monoidal structure morphism dual to >+<.

filtrate . uncurry (>+<) = id
uncurry (>+<) . filtrate = id

Minimal complete definition

Nothing

Methods

filtrate :: p (Either a c) (Either b d) -> (p a b, p c d) Source #

unleft = fst . filtrate = lmap Left . mapMaybe (either Just (const Nothing))
unright = snd . filtrate = 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.

filtrate = mfiltrate

filtrate has a default for Choice & Cochoice partial profunctors.

default filtrate :: Choice p => p (Either a c) (Either b d) -> (p a b, p c d) Source #

Instances

Instances details
Categorized (Item s) => Filtrator (Parsector s) Source # 
Instance details

Defined in Data.Profunctor.Grammar.Parsector

Methods

filtrate :: Parsector s (Either a c) (Either b d) -> (Parsector s a b, Parsector s c d) Source #

Filtrator p => Filtrator (Coyoneda p) Source # 
Instance details

Defined in Data.Profunctor.Filtrator

Methods

filtrate :: Coyoneda p (Either a c) (Either b d) -> (Coyoneda p a b, Coyoneda p c d) Source #

Filtrator p => Filtrator (Yoneda p) Source # 
Instance details

Defined in Data.Profunctor.Filtrator

Methods

filtrate :: Yoneda p (Either a c) (Either b d) -> (Yoneda p a b, Yoneda p c d) Source #

Filtrator (Binocular a b) Source # 
Instance details

Defined in Control.Lens.Bifocal

Methods

filtrate :: Binocular a b (Either a0 c) (Either b0 d) -> (Binocular a b a0 b0, Binocular a b c d) Source #

Filtrator (PartialExchange a b) Source # 
Instance details

Defined in Data.Profunctor.Filtrator

Methods

filtrate :: PartialExchange a b (Either a0 c) (Either b0 d) -> (PartialExchange a b a0 b0, PartialExchange a b c d) Source #

Filterable f => Filtrator (Parsor s f) Source # 
Instance details

Defined in Data.Profunctor.Grammar

Methods

filtrate :: Parsor s f (Either a c) (Either b d) -> (Parsor s f a b, Parsor s f c d) Source #

Filterable f => Filtrator (Printor s f) Source # 
Instance details

Defined in Data.Profunctor.Grammar

Methods

filtrate :: Printor s f (Either a c) (Either b d) -> (Printor s f a b, Printor s f c d) Source #

(Profunctor p, forall x. Functor (p x), Filterable f) => Filtrator (WrappedPafb f p) Source # 
Instance details

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 # 
Instance details

Defined in Data.Profunctor.Filtrator

Methods

filtrate :: Forget r (Either a c) (Either b d) -> (Forget r a b, Forget r c d) Source #

(Filterable f, Traversable f) => Filtrator (Star f) Source # 
Instance details

Defined in Data.Profunctor.Filtrator

Methods

filtrate :: Star f (Either a c) (Either b d) -> (Star f a b, Star f c d) Source #

Filterable f => Filtrator (Joker f :: Type -> Type -> Type) Source # 
Instance details

Defined in Data.Profunctor.Filtrator

Methods

filtrate :: Joker f (Either a c) (Either b d) -> (Joker f a b, Joker f c d) Source #

mfiltrate Source #

Arguments

:: (Monadic p, Alternator p) 
=> p (Either a c) (Either b d)

partition Either

-> (p a b, p c d) 

A Monadic Alternator has an equivalent to filtrate, given by mfiltrate.

filtrate = mfiltrate