| Safe Haskell | Trustworthy |
|---|---|
| Language | Haskell2010 |
Data.Functor.Coapply
Contents
Synopsis
- type (+) = Either
- class Functor f => Coapply f where
- apply :: Apply f => (f a, f b) -> f (a, b)
- select :: Functor f => f (a, b) -> (f a, f b)
- coselect :: Functor f => (f a + f b) -> f (a + b)
- coeval :: Coapply f => f (a + b) -> f (a + b)
- appendl :: Semigroup a => a -> (a + b) -> a + b
- concatl :: [a + b] -> [a]
- concatr :: [a + b] -> [b]
- concatl' :: [a + b] -> [a]
- concatr' :: [a + b] -> [b]
- type Select f = (Coapply f, Apply f)
- eitherS :: Select f => f (a + b) -> f (a -> c) -> f (b -> c) -> f c
- branch :: Select f => f Bool -> f a -> f a -> f a
- bindBool :: Select f => f Bool -> (Bool -> f a) -> f a
- class Functor g => Distributive1 g where
- distribute1 :: Coapply f => f (g a) -> g (f a)
- collect1 :: Coapply f => (a -> g b) -> f a -> g (f b)
- cotraverse1 :: Coapply f => Distributive1 g => (f a -> b) -> f (g a) -> g b
Types
Coapply
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.
Select
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"
Distributive1
class Functor g => Distributive1 g where Source #
Minimal complete definition
Methods
distribute1 :: Coapply f => f (g a) -> g (f a) Source #
The dual of sequence1
distribute1=collect1iddistribute1.distribute1=id
collect1 :: Coapply f => (a -> g b) -> f a -> g (f b) Source #
collect1f =distribute1.fmapffmapf =runIdentity.collect1(Identity. f)fmapdistribute1.collect1f =getCompose.collect1(Compose. f)
Instances
| Distributive1 Identity Source # | |
| Distributive1 NonEmpty Source # | |
| Distributive1 Par1 Source # | |
| Distributive1 Maybe Source # | |
| Distributive1 List Source # | |
Defined in Data.Functor.Coapply | |
| Distributive1 (U1 :: Type -> Type) Source # | |
| Distributive1 (Tagged t) Source # | |
| Distributive1 m => Distributive1 (ReaderT r m) Source # | |
| (Distributive1 f, Distributive1 g) => Distributive1 (Product f g) Source # | |
| (Distributive1 a, Distributive1 b) => Distributive1 (a :*: b) Source # | |
| Distributive1 ((->) r) Source # | |
Defined in Data.Functor.Coapply | |
| (Distributive1 a, Distributive1 b) => Distributive1 (a :.: b) Source # | |
cotraverse1 :: Coapply f => Distributive1 g => (f a -> b) -> f (g a) -> g b Source #
The dual of traverse1
cotraverse1f =fmapf .distribute1