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 |
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)
(<.>) :: 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
Wrappers
newtype WrappedApplicative f a Source
Wrap an Applicative
to be used as a member of Apply
WrapApplicative | |
|
Functor f => Functor (WrappedApplicative f) Source | |
Applicative f => Applicative (WrappedApplicative f) Source | |
Alternative f => Alternative (WrappedApplicative f) Source | |
Applicative f => Apply (WrappedApplicative f) Source | |
Alternative f => Alt (WrappedApplicative f) Source | |
Alternative f => Plus (WrappedApplicative f) Source |
newtype MaybeApply f a Source
Transform a Apply into an Applicative by adding a unit.
MaybeApply | |
|
Functor f => Functor (MaybeApply f) Source | |
Apply f => Applicative (MaybeApply f) Source | |
Comonad f => Comonad (MaybeApply f) Source | |
Extend f => Extend (MaybeApply f) Source | |
Apply f => Apply (MaybeApply f) Source |
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)
Bind [] Source | |
Bind IO Source | |
Bind Identity Source | |
Bind Maybe Source | |
Bind IntMap Source | |
Bind Tree Source | |
Bind Seq Source | |
Bind Option Source | |
Bind NonEmpty Source | |
Bind ((->) m) Source | |
Bind (Either a) Source | |
Semigroup m => Bind ((,) m) Source | |
Monad m => Bind (WrappedMonad m) Source | |
Bind m => Bind (IdentityT m) Source | |
Ord k => Bind (Map k) Source | |
(Functor m, Monad m) => Bind (MaybeT m) Source | |
(Apply m, Monad m) => Bind (ListT m) Source | |
(Bind f, Bind g) => Bind (Product f g) Source | |
(Bind m, Semigroup w) => Bind (WriterT w m) Source | |
(Bind m, Semigroup w) => Bind (WriterT w m) Source | |
(Functor m, Monad m) => Bind (ErrorT e m) Source | |
(Functor m, Monad m) => Bind (ExceptT e m) Source | |
Bind m => Bind (StateT s m) Source | |
Bind m => Bind (StateT s m) Source | |
Bind m => Bind (ReaderT e m) Source | |
Bind (ContT r m) Source | |
(Bind m, Semigroup w) => Bind (RWST r w s m) Source | |
(Bind m, Semigroup w) => Bind (RWST r w s m) Source |
Biappliable bifunctors
class Bifunctor p => Biapply p where Source
(<<.>>) :: p (a -> b) (c -> d) -> p a c -> p b d infixl 4 Source
Biapply (,) Source | |
Biapply Const Source | |
Biapply Arg Source | |
Semigroup x => Biapply ((,,) x) Source | |
Biapply p => Biapply (WrappedBifunctor p) Source | |
Apply g => Biapply (Joker g) Source | |
Biapply p => Biapply (Flip p) Source | |
Apply f => Biapply (Clown f) Source | |
Biapply (Tagged *) Source | |
(Semigroup x, Semigroup y) => Biapply ((,,,) x y) Source | |
(Apply f, Biapply p) => Biapply (Tannen f p) Source | |
(Biapply p, Biapply q) => Biapply (Product p q) Source | |
(Semigroup x, Semigroup y, Semigroup z) => Biapply ((,,,,) x y z) Source | |
(Biapply p, Apply f, Apply g) => Biapply (Biff p f g) Source |