coapplicative
Safe HaskellTrustworthy
LanguageHaskell2010

Data.Functor.Coapply

Synopsis

Types

Coapply

class Functor f => Coapply f where Source #

Methods

coapply :: f (a + b) -> f a + f b Source #

Instances

Instances details
Coapply Identity Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

coapply :: Identity (a + b) -> Identity a + Identity b Source #

Coapply NonEmpty Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

coapply :: NonEmpty (a + b) -> NonEmpty a + NonEmpty b Source #

Coapply Maybe Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

coapply :: Maybe (a + b) -> Maybe a + Maybe b Source #

Coapply List Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

coapply :: [a + b] -> [a] + [b] Source #

Coapply ((,) r) Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

coapply :: (r, a + b) -> (r, a) + (r, b) Source #

Coapply (Const r :: Type -> Type) Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

coapply :: Const r (a + b) -> Const r a + Const r b Source #

Coapply (Tagged k) Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

coapply :: Tagged k (a + b) -> Tagged k a + Tagged k b Source #

Monoid r => Coapply ((->) r) Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

coapply :: (r -> (a + b)) -> (r -> a) + (r -> b) Source #

(Coapply f, Coapply g) => Coapply (Compose f g) Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

coapply :: Compose f g (a + b) -> Compose f g a + Compose f g b Source #

apply :: Apply f => (f a, f b) -> f (a, b) Source #

select :: Functor f => f (a, b) -> (f a, f b) Source #

coselect :: Functor f => (f a + f b) -> f (a + b) Source #

coeval :: Coapply f => f (a + b) -> f (a + b) Source #

Evaluate a coapplicative expression, exiting on the first Left if it exists.

>>> coeval $ Left "foo" :| [Right "bar"]
Left "foo" :| []
>>> coeval $ Right "foo" :| [Right "bar"]
Right "foo" :| [Right "bar"]

appendl :: Semigroup a => a -> (a + b) -> a + b Source #

Append two semigroup values or return the Right one.

concatl :: [a + b] -> [a] Source #

concatr :: [a + b] -> [b] Source #

concatl' :: [a + b] -> [a] Source #

concatr' :: [a + b] -> [b] Source #

Select

type Select f = (Coapply f, Apply f) Source #

eitherS :: Select f => f (a + b) -> f (a -> c) -> f (b -> c) -> f c Source #

branch :: Select f => f Bool -> f a -> f a -> f a Source #

Branch on a boolean value, skipping unnecessary effects.

>>> head $ branch (True :| []) (print "foo" :| []) (print "bar" :| [])
"foo"

bindBool :: Select f => f Bool -> (Bool -> f a) -> f a Source #

Distributive1

class Functor g => Distributive1 g where Source #

Minimal complete definition

distribute1 | collect1

Methods

distribute1 :: Coapply f => f (g a) -> g (f a) Source #

collect1 :: Coapply f => (a -> g b) -> f a -> g (f b) Source #

Instances

Instances details
Distributive1 Identity Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

distribute1 :: Coapply f => f (Identity a) -> Identity (f a) Source #

collect1 :: Coapply f => (a -> Identity b) -> f a -> Identity (f b) Source #

Distributive1 NonEmpty Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

distribute1 :: Coapply f => f (NonEmpty a) -> NonEmpty (f a) Source #

collect1 :: Coapply f => (a -> NonEmpty b) -> f a -> NonEmpty (f b) Source #

Distributive1 Par1 Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

distribute1 :: Coapply f => f (Par1 a) -> Par1 (f a) Source #

collect1 :: Coapply f => (a -> Par1 b) -> f a -> Par1 (f b) Source #

Distributive1 Maybe Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

distribute1 :: Coapply f => f (Maybe a) -> Maybe (f a) Source #

collect1 :: Coapply f => (a -> Maybe b) -> f a -> Maybe (f b) Source #

Distributive1 List Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

distribute1 :: Coapply f => f [a] -> [f a] Source #

collect1 :: Coapply f => (a -> [b]) -> f a -> [f b] Source #

Distributive1 (U1 :: Type -> Type) Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

distribute1 :: Coapply f => f (U1 a) -> U1 (f a) Source #

collect1 :: Coapply f => (a -> U1 b) -> f a -> U1 (f b) Source #

Distributive1 (Tagged t) Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

distribute1 :: Coapply f => f (Tagged t a) -> Tagged t (f a) Source #

collect1 :: Coapply f => (a -> Tagged t b) -> f a -> Tagged t (f b) Source #

Distributive1 m => Distributive1 (ReaderT r m) Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

distribute1 :: Coapply f => f (ReaderT r m a) -> ReaderT r m (f a) Source #

collect1 :: Coapply f => (a -> ReaderT r m b) -> f a -> ReaderT r m (f b) Source #

(Distributive1 f, Distributive1 g) => Distributive1 (Product f g) Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

distribute1 :: Coapply f0 => f0 (Product f g a) -> Product f g (f0 a) Source #

collect1 :: Coapply f0 => (a -> Product f g b) -> f0 a -> Product f g (f0 b) Source #

(Distributive1 a, Distributive1 b) => Distributive1 (a :*: b) Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

distribute1 :: Coapply f => f ((a :*: b) a0) -> (a :*: b) (f a0) Source #

collect1 :: Coapply f => (a0 -> (a :*: b) b0) -> f a0 -> (a :*: b) (f b0) Source #

Distributive1 ((->) r) Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

distribute1 :: Coapply f => f (r -> a) -> r -> f a Source #

collect1 :: Coapply f => (a -> r -> b) -> f a -> r -> f b Source #

(Distributive1 a, Distributive1 b) => Distributive1 (a :.: b) Source # 
Instance details

Defined in Data.Functor.Coapply

Methods

distribute1 :: Coapply f => f ((a :.: b) a0) -> (a :.: b) (f a0) Source #

collect1 :: Coapply f => (a0 -> (a :.: b) b0) -> f a0 -> (a :.: b) (f b0) Source #

cotraverse1 :: Coapply f => Distributive1 g => (f a -> b) -> f (g a) -> g b Source #