| Copyright | (C) 2011-2015 Edward Kmett |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | Edward Kmett <ekmett@gmail.com> |
| Stability | provisional |
| Portability | portable |
| Safe Haskell | Safe |
| Language | Haskell98 |
Data.Functor.Bind.Class
Description
This module is used to resolve the cyclic we get from defining these
classes here rather than in a package upstream. Otherwise we'd get
orphaned heads for many instances on the types in transformers and bifunctors.
- class Functor f => Apply f where
- newtype WrappedApplicative f a = WrapApplicative {
- unwrapApplicative :: f a
- newtype MaybeApply f a = MaybeApply {
- runMaybeApply :: Either (f a) a
- class Apply m => Bind m where
- apDefault :: Bind f => f (a -> b) -> f a -> f b
- returning :: Functor f => f a -> (a -> b) -> f b
- class Bifunctor p => Biapply p where
Applyable functors
class Functor f => Apply f where Source
A strong lax semi-monoidal endofunctor.
This is equivalent to an Applicative without pure.
Laws:
associative composition: (.) <$> u <.> v <.> w = u <.> (v <.> w)
Minimal complete definition
Methods
(<.>) :: f (a -> b) -> f a -> f b infixl 4 Source
(.>) :: f a -> f b -> f b infixl 4 Source
a .> b = const id <$> a <.> b
(<.) :: f a -> f b -> f a infixl 4 Source
a <. b = const <$> a <.> b
Instances
Wrappers
newtype WrappedApplicative f a Source
Wrap an Applicative to be used as a member of Apply
Constructors
| WrapApplicative | |
Fields
| |
Instances
| Alternative f => Alternative (WrappedApplicative f) | |
| Functor f => Functor (WrappedApplicative f) | |
| Applicative f => Applicative (WrappedApplicative f) | |
| Applicative f => Apply (WrappedApplicative f) | |
| Alternative f => Alt (WrappedApplicative f) | |
| Alternative f => Plus (WrappedApplicative f) |
newtype MaybeApply f a Source
Transform a Apply into an Applicative by adding a unit.
Constructors
| MaybeApply | |
Fields
| |
Instances
| Functor f => Functor (MaybeApply f) | |
| Apply f => Applicative (MaybeApply f) | |
| Comonad f => Comonad (MaybeApply f) | |
| Extend f => Extend (MaybeApply f) | |
| Apply f => Apply (MaybeApply f) |
Bindable functors
class Apply m => Bind m where Source
Minimal definition: Either join or >>-
If defining both, then the following laws (the default definitions) must hold:
join = (>>- id) m >>- f = join (fmap f m)
Laws:
induced definition of <.>: f <.> x = f >>- (<$> x)
Finally, there are two associativity conditions:
associativity of (>>-): (m >>- f) >>- g == m >>- (\x -> f x >>- g) associativity of join: join . join = join . fmap join
These can both be seen as special cases of the constraint that
associativity of (->-): (f ->- g) ->- h = f ->- (g ->- h)
Instances
| Bind [] | |
| Bind IO | |
| Bind Maybe | |
| Bind Identity | |
| Bind IntMap | |
| Bind Tree | |
| Bind Seq | |
| Bind Option | |
| Bind NonEmpty | |
| Bind ((->) m) | |
| Bind (Either a) | |
| Semigroup m => Bind ((,) m) | |
| Monad m => Bind (WrappedMonad m) | |
| Bind m => Bind (IdentityT m) | |
| Ord k => Bind (Map k) | |
| (Functor m, Monad m) => Bind (MaybeT m) | |
| (Apply m, Monad m) => Bind (ListT m) | |
| (Bind f, Bind g) => Bind (Product f g) | |
| (Bind m, Semigroup w) => Bind (WriterT w m) | |
| (Bind m, Semigroup w) => Bind (WriterT w m) | |
| (Functor m, Monad m) => Bind (ErrorT e m) | |
| (Functor m, Monad m) => Bind (ExceptT e m) | |
| Bind m => Bind (StateT s m) | |
| Bind m => Bind (StateT s m) | |
| Bind m => Bind (ReaderT e m) | |
| Bind (ContT r m) | |
| (Bind m, Semigroup w) => Bind (RWST r w s m) | |
| (Bind m, Semigroup w) => Bind (RWST r w s m) |
Biappliable bifunctors
class Bifunctor p => Biapply p where Source
Minimal complete definition
Methods
(<<.>>) :: p (a -> b) (c -> d) -> p a c -> p b d infixl 4 Source
Instances
| Biapply (,) | |
| Biapply Const | |
| Biapply Arg | |
| Semigroup x => Biapply ((,,) x) | |
| Biapply p => Biapply (WrappedBifunctor p) | |
| Apply g => Biapply (Joker g) | |
| Biapply p => Biapply (Flip p) | |
| Apply f => Biapply (Clown f) | |
| Biapply (Tagged *) | |
| (Semigroup x, Semigroup y) => Biapply ((,,,) x y) | |
| (Apply f, Biapply p) => Biapply (Tannen f p) | |
| (Biapply p, Biapply q) => Biapply (Product p q) | |
| (Semigroup x, Semigroup y, Semigroup z) => Biapply ((,,,,) x y z) | |
| (Biapply p, Apply f, Apply g) => Biapply (Biff p f g) |