Modules 26
Data.Functor.Bind
provisionalFunctors
(<$>) :: (Functor f) => (a -> b) -> f a -> f b
($>) :: (Functor f) => f a -> b -> f b
Replace every value with the given one.
Applyable functors
class Functor f => Apply f
A strong lax semi-monoidal endofunctor.
This is equivalent to an Applicative without pure.
Laws:
('.') '<$>' u '<.>' v '<.>' w = u '<.>' (v '<.>' w)
x '<.>' (f '<$>' y) = ('.' f) '<$>' x '<.>' y
f '<$>' (x '<.>' y) = (f '.') '<$>' x '<.>' y
The laws imply that `.>` and `<.` really ignore their left and right results, respectively, and really return their right and left results, respectively. Specifically,
(mf '<$>' m) '.>' (nf '<$>' n) = nf '<$>' (m '.>' n)
(mf '<$>' m) '<.' (nf '<$>' n) = mf '<$>' (m '<.' n)
(<.>) :: f (a -> b) -> f a -> f b
(.>) :: f a -> f b -> f b
a .> b = const id <$> a <.> b
(<.) :: f a -> f b -> f a
a <. b = const <$> a <.> b
liftF2 :: (a -> b -> c) -> f a -> f b -> f c
Lift a binary function into a comonad with zipping
(<..>) :: Apply w => w a -> w (a -> b) -> w b
A variant of <.> with the arguments reversed.
liftF3 :: Apply w => (a -> b -> c -> d) -> w a -> w b -> w c -> w d
Lift a ternary function into a comonad with zipping
Wrappers
newtype WrappedApplicative f a
Wrap an Applicative to be used as a member of Apply
WrapApplicative :: f a -> WrappedApplicative f a
unwrapApplicative :: WrappedApplicative f a -> f a
newtype MaybeApply f a
Transform an Apply into an Applicative by adding a unit.
MaybeApply :: Either (f a) a -> MaybeApply f a
runMaybeApply :: MaybeApply f a -> Either (f a) a
Bindable functors
class Apply m => Bind m
A Monad sans return.
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 joinThese can both be seen as special cases of the constraint that
associativity of (->-): (f ->- g) ->- h = f ->- (g ->- h)(>>-) :: m a -> (a -> m b) -> m b
join :: m (m a) -> m a
gbind :: (Generic1 m, Bind (Rep1 m)) => m a -> (a -> m b) -> m b
Generic >>-. Caveats:
Will not compile if
mis a sum type.Will not compile if
mcontains fields that do not mention its type variable.Will not compile if
mcontains fields where the type variable appears underneath the composition of type constructors (e.g.,f (g a)).May do redundant work, due to the nature of the
Bindinstance for (:*:)
(-<<) :: Bind m => (a -> m b) -> m a -> m b
(-<-) :: Bind m => (b -> m c) -> (a -> m b) -> a -> m c
(->-) :: Bind m => (a -> m b) -> (b -> m c) -> a -> m c
apDefault :: Bind f => f (a -> b) -> f a -> f b
returning :: Functor f => f a -> (a -> b) -> f b
- Maintainer
- Edward Kmett <ekmett@gmail.com>
- Portability
- portable
- Copyright
- (C) 2011-2015 Edward Kmett
- License
- BSD-style (see the file LICENSE)
Build record and source files
Community contribution. The service has not verified this documentation.
Target: Linux on x86-64. Some inferred types and resolved links are not available.
Generator: aihc-haddock-858b1951-web-1
Metadata snapshot: 4ac4693dc44e2bb370a93502d1bf29784374032a00ad7b3d02803e3d433c0b16
Open the dependency plan · Download the documentation model
- StateVar-1.2.2 · Cabal revision 0 · Cabal file · Source archive
- aihc-base-4.21.2.0 · Core library · Cabal file
- aihc-internal-9.1204.0 · Core library · Cabal file
- aihc-prim-0.13.0 · Core library · Cabal file
- aihc-rts-1.0.2 · Core library · Cabal file
- aihc-template-haskell-2.23.0.0 · Core library · Cabal file
- array-0.5.8.0 · Cabal revision 2 · Cabal file · Source archive
- assoc-1.1.1 · Cabal revision 2 · Cabal file · Source archive
- base-orphans-0.9.4 · Cabal revision 0 · Cabal file · Source archive
- bifunctors-5.6.3 · Cabal revision 1 · Cabal file · Source archive
- binary-0.8.9.3 · Cabal revision 0 · Cabal file · Source archive
- bytestring-0.12.2.0 · Cabal revision 1 · Cabal file · Source archive
- comonad-5.0.10 · Cabal revision 0 · Cabal file · Source archive
- containers-0.8.1 · Cabal revision 0 · Cabal file · Source archive
- contravariant-1.5.6 · Cabal revision 0 · Cabal file · Source archive
- deepseq-1.5.2.0 · Cabal revision 0 · Cabal file · Source archive
- distributive-0.6.3 · Cabal revision 0 · Cabal file · Source archive
- exceptions-0.10.12 · Cabal revision 2 · Cabal file · Source archive
- filepath-1.5.5.0 · Cabal revision 0 · Cabal file · Source archive
- hashable-1.5.1.0 · Cabal revision 0 · Cabal file · Source archive
- indexed-traversable-0.1.5 · Cabal revision 0 · Cabal file · Source archive
- mtl-2.3.2 · Cabal revision 1 · Cabal file · Source archive
- os-string-2.0.11 · Cabal revision 0 · Cabal file · Source archive
- semigroupoids-6.0.2 · Cabal revision 1 · Cabal file · Source archive
- stm-2.5.3.1 · Cabal revision 1 · Cabal file · Source archive
- system-cxx-std-lib-1.0 · Core library · Cabal file
- tagged-0.9 · Cabal revision 0 · Cabal file · Source archive
- text-2.1.4 · Cabal revision 0 · Cabal file · Source archive
- th-abstraction-0.7.2.0 · Cabal revision 0 · Cabal file · Source archive
- transformers-0.6.3.0 · Cabal revision 2 · Cabal file · Source archive
- transformers-compat-0.8 · Cabal revision 0 · Cabal file · Source archive
- unordered-containers-0.2.21 · Cabal revision 2 · Cabal file · Source archive