Community
Modules 26

Data.Functor.Bind.Class

provisional

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.

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

Wrappers

newtype MaybeApply f a

Transform an Apply into an Applicative by adding a unit.

(<.*>) :: (Apply f) => f (a -> b) -> MaybeApply f a -> f b

Apply a non-empty container of functions to a possibly-empty-with-unit container of values.

(<*.>) :: (Apply f) => MaybeApply f (a -> b) -> f a -> f b

Apply a possibly-empty-with-unit container of functions to a non-empty container of values.

traverse1Maybe :: (Traversable t, Apply f) => (a -> f b) -> t a -> MaybeApply f (t b)

Traverse a Traversable using Apply, getting the results back in a MaybeApply.

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 join

These 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

apDefault :: Bind f => f (a -> b) -> f a -> f b

returning :: Functor f => f a -> (a -> b) -> f b

Biappliable bifunctors

class Bifunctor p => Biapply p

(<<.>>) :: p (a -> b) (c -> d) -> p a c -> p b d

(.>>) :: p a b -> p c d -> p c d

a '.>' b ≡ 'const' 'id' '<$>' a '<.>' b

(<<.) :: p a b -> p c d -> p a b

a '<.' b ≡ 'const' '<$>' a '<.>' b

Instances

140
  • instance Apply (Tagged a)
  • instance Apply Proxy
  • instance Apply f => Apply (Backwards f)
  • instance (Apply f, Apply g) => Apply (Compose f g)
  • instance Semigroup f => Apply (Constant f)

    A Constant f is not Applicative unless its f is a Monoid, but it is an instance of Apply

  • instance Apply f => Apply (Lift f)
  • instance (Apply f, Apply g) => Apply (Functor.Product f g)
  • instance Apply f => Apply (Reverse f)
  • instance Semigroup m => Apply ((,) m)

    A '(,)' m is not Applicative unless its m is a Monoid, but it is an instance of Apply

  • instance Apply NonEmpty
  • instance Apply (Either a)
  • instance Semigroup m => Apply (Const m)

    A Const m is not Applicative unless its m is a Monoid, but it is an instance of Apply

  • instance Apply ((->) m)
  • instance Apply ZipList
  • instance Apply []
  • instance Apply IO
  • instance Apply Maybe
  • instance Apply Identity
  • instance Apply w => Apply (IdentityT w)
  • instance Monad m => Apply (WrappedMonad m)
  • instance Arrow a => Apply (WrappedArrow a b)
  • instance Apply Complex
  • instance Apply Q
  • instance Ord k => Apply (Map k)

    A 'Map k' is not Applicative, but it is an instance of Apply

  • instance Apply IntMap

    An IntMap is not Applicative, but it is an instance of Apply

  • instance Apply Seq
  • instance Apply Tree
  • instance (Hashable k, Eq k) => Apply (HashMap k)

    A 'HashMap k' is not Applicative, but it is an instance of Apply

  • instance (Functor m, Monad m) => Apply (MaybeT m)
  • instance (Functor m, Monad m) => Apply (ExceptT e m)
  • instance Apply m => Apply (ReaderT e m)
  • instance (Apply m, Semigroup w) => Apply (Strict.WriterT w m)

    A WriterT w m is not Applicative unless its w is a Monoid, but it is an instance of Apply

  • instance (Apply m, Semigroup w) => Apply (Lazy.WriterT w m)

    A WriterT w m is not Applicative unless its w is a Monoid, but it is an instance of Apply

  • instance Apply (ST s)
  • instance Apply (Lazy.ST s)
  • instance (Bind m) => Apply (CPS.WriterT w m)
  • instance Bind m => Apply (Strict.StateT s m)
  • instance Bind m => Apply (Lazy.StateT s m)
  • instance (Bind m, Semigroup w) => Apply (Strict.RWST r w s m)

    An RWST r w s m is not Applicative unless its w is a Monoid, but it is an instance of Apply

  • instance (Bind m, Semigroup w) => Apply (Lazy.RWST r w s m)

    An RWST r w s m is not Applicative unless its w is a Monoid, but it is an instance of Apply

  • instance (Bind m) => Apply (CPS.RWST r w s m)
  • instance Apply (ContT r m)
  • instance (Semigroup e, Apply w) => Apply (EnvT e w)

    An EnvT e w is not Applicative unless its e is a Monoid, but it is an instance of Apply

  • instance (Apply w, Semigroup s) => Apply (StoreT s w)

    A StoreT s w is not Applicative unless its s is a Monoid, but it is an instance of Apply

  • instance Apply w => Apply (TracedT m w)
  • instance Functor f => Functor (WrappedApplicative f)
  • instance Applicative f => Apply (WrappedApplicative f)
  • instance Applicative f => Applicative (WrappedApplicative f)
  • instance Alternative f => Alternative (WrappedApplicative f)
  • instance Functor f => Functor (MaybeApply f)
  • instance Apply f => Apply (MaybeApply f)
  • instance Apply f => Applicative (MaybeApply f)
  • instance Extend f => Extend (MaybeApply f)
  • instance Comonad f => Comonad (MaybeApply f)
  • instance Apply (Cokleisli w a)
  • instance Apply Down
  • instance Apply Monoid.Sum
  • instance Apply Monoid.Product
  • instance Apply Monoid.Dual
  • instance Apply Monoid.First
  • instance Apply Monoid.Last
  • instance Apply f => Apply (Monoid.Alt f)
  • instance Apply Semigroup.First
  • instance Apply Semigroup.Last
  • instance Apply Semigroup.Min
  • instance Apply Semigroup.Max
  • instance (Apply f, Apply g) => Apply (f :*: g)
  • instance Apply f => Apply (M1 i t f)
  • instance Apply f => Apply (Rec1 f)
  • instance (Apply f, Apply g) => Apply (f :.: g)
  • instance Apply U1
  • instance Semigroup c => Apply (K1 i c)

    A K1 i c is not Applicative unless its c is a Monoid, but it is an instance of Apply

  • instance Apply Par1
  • instance Apply Generics.V1

    A V1 is not Applicative, but it is an instance of Apply

  • instance Semigroup m => Bind ((,) m)

    A '(,)' m is not a Monad unless its m is a Monoid, but it is an instance of Bind

  • instance Bind (Tagged a)
  • instance Bind Proxy
  • instance Bind (Either a)
  • instance (Bind f, Bind g) => Bind (Functor.Product f g)
  • instance Bind ((->) m)
  • instance Bind []
  • instance Bind NonEmpty
  • instance Bind IO
  • instance Bind (ST s)
  • instance Bind (Lazy.ST s)
  • instance Bind Maybe
  • instance Bind Identity
  • instance Bind Q
  • instance Bind m => Bind (IdentityT m)
  • instance Monad m => Bind (WrappedMonad m)
  • instance (Functor m, Monad m) => Bind (MaybeT m)
  • instance (Functor m, Monad m) => Bind (ExceptT e m)
  • instance Bind m => Bind (ReaderT e m)
  • instance (Bind m, Semigroup w) => Bind (Lazy.WriterT w m)

    A WriterT w m is not a Monad unless its w is a Monoid, but it is an instance of Bind

  • instance (Bind m, Semigroup w) => Bind (Strict.WriterT w m)

    A WriterT w m is not a Monad unless its w is a Monoid, but it is an instance of Bind

  • instance (Bind m) => Bind (CPS.WriterT w m)
  • instance Bind m => Bind (Lazy.StateT s m)
  • instance Bind m => Bind (Strict.StateT s m)
  • instance (Bind m, Semigroup w) => Bind (Lazy.RWST r w s m)

    An RWST r w s m is not a Monad unless its w is a Monoid, but it is an instance of Bind

  • instance (Bind m, Semigroup w) => Bind (Strict.RWST r w s m)

    An RWST r w s m is not a Monad unless its w is a Monoid, but it is an instance of Bind

  • instance (Bind m) => Bind (CPS.RWST r w s m)
  • instance Bind (ContT r m)
  • instance Bind Complex
  • instance Ord k => Bind (Map k)

    A 'Map k' is not a Monad, but it is an instance of Bind

  • instance Bind IntMap

    An IntMap is not a Monad, but it is an instance of Bind

  • instance Bind Seq
  • instance Bind Tree
  • instance (Hashable k, Eq k) => Bind (HashMap k)

    A 'HashMap k' is not a Monad, but it is an instance of Bind

  • instance Bind Down
  • instance Bind Monoid.Sum
  • instance Bind Monoid.Product
  • instance Bind Monoid.Dual
  • instance Bind Monoid.First
  • instance Bind Monoid.Last
  • instance Bind f => Bind (Monoid.Alt f)
  • instance Bind Semigroup.First
  • instance Bind Semigroup.Last
  • instance Bind Semigroup.Min
  • instance Bind Semigroup.Max
  • instance Bind Generics.V1

    A V1 is not a Monad, but it is an instance of Bind

  • instance Bind Generics.U1
  • instance Bind f => Bind (Generics.M1 i c f)
  • instance Bind m => Bind (Generics.Rec1 m)
  • instance Bind Generics.Par1
  • instance (Bind f, Bind g) => Bind (f :*: g)
  • instance Biapply (,)
  • instance Biapply Arg
  • instance Semigroup x => Biapply ((,,) x)
  • instance (Semigroup x, Semigroup y) => Biapply ((,,,) x y)
  • instance (Semigroup x, Semigroup y, Semigroup z) => Biapply ((,,,,) x y z)
  • instance Biapply Const
  • instance Biapply Tagged
  • instance (Biapply p, Apply f, Apply g) => Biapply (Biff p f g)
  • instance Apply f => Biapply (Clown f)
  • instance Biapply p => Biapply (Flip p)
  • instance Apply g => Biapply (Joker g)
  • instance Biapply p => Apply (Join p)
  • instance (Biapply p, Biapply q) => Biapply (Bifunctor.Product p q)
  • instance (Apply f, Biapply p) => Biapply (Tannen f p)
  • instance Biapply p => Biapply (WrappedBifunctor p)
Maintainer
Edward Kmett <ekmett@gmail.com>
Portability
portable
Copyright
(C) 2011-2018 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

Import a package

Enter a package name and an exact version from Hackage. The site contains imported versions only.