semigroupoids-5.0.0.1: Semigroupoids: Category sans id

Copyright(C) 2011-2015 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityprovisional
Portabilityportable
Safe HaskellSafe
LanguageHaskell98

Data.Functor.Bind.Class

Contents

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.

Synopsis

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

Apply [] 
Apply IO 
Apply ZipList 
Apply Maybe 
Apply Identity 
Apply IntMap

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

Apply Tree 
Apply Seq 
Apply Option 
Apply NonEmpty 
Apply ((->) m) 
Apply (Either a) 
Semigroup m => Apply ((,) m) 
Semigroup m => Apply (Const m) 
Monad m => Apply (WrappedMonad m) 
Biapply p => Apply (Join p) 
Apply w => Apply (IdentityT w) 
Ord k => Apply (Map k)

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

Apply f => Apply (Reverse f) 
Apply f => Apply (Backwards f) 
(Functor m, Monad m) => Apply (MaybeT m) 
Apply m => Apply (ListT m) 
Apply f => Apply (Lift f) 
Semigroup f => Apply (Constant f) 
Apply f => Apply (MaybeApply f) 
Applicative f => Apply (WrappedApplicative f) 
Arrow a => Apply (WrappedArrow a b) 
Apply w => Apply (TracedT m w) 
(Apply w, Semigroup s) => Apply (StoreT s w) 
(Semigroup e, Apply w) => Apply (EnvT e w) 
Apply (Cokleisli w a) 
(Apply f, Apply g) => Apply (Product f g) 
(Apply f, Apply g) => Apply (Compose f g) 
(Apply m, Semigroup w) => Apply (WriterT w m) 
(Apply m, Semigroup w) => Apply (WriterT w m) 
(Functor m, Monad m) => Apply (ErrorT e m) 
(Functor m, Monad m) => Apply (ExceptT e m) 
Bind m => Apply (StateT s m) 
Bind m => Apply (StateT s m) 
Apply m => Apply (ReaderT e m) 
Apply (ContT r m) 
Apply f => Apply (Static f a) 
(Bind m, Semigroup w) => Apply (RWST r w s m) 
(Bind m, Semigroup w) => Apply (RWST r w s m) 

Wrappers

newtype MaybeApply f a Source

Transform a Apply into an Applicative by adding a unit.

Constructors

MaybeApply 

Fields

runMaybeApply :: Either (f a) a
 

Bindable functors

class Apply m => Bind m where Source

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)

Minimal complete definition

(>>-) | join

Methods

(>>-) :: m a -> (a -> m b) -> m b infixl 1 Source

join :: m (m a) -> m a Source

Instances

Bind [] 
Bind IO 
Bind Maybe 
Bind Identity 
Bind IntMap

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

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)

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

(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) 

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

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

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

(.>>) :: p a b -> p c d -> p c d infixl 4 Source

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

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

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

Instances