Portability  portable 

Stability  experimental 
Maintainer  libraries@haskell.org 
Basic arrow definitions, based on
Generalising Monads to Arrows, by John Hughes,
Science of Computer Programming 37, pp67111, May 2000.
plus a couple of definitions (returnA
and loop
) from
A New Notation for Arrows, by Ross Paterson, in ICFP 2001,
Firenze, Italy, pp229240.
See these papers for the equations these combinators are expected to
satisfy. These papers and more information on arrows can be found at
http://www.haskell.org/arrows/.
 class Category a => Arrow a where
 newtype Kleisli m a b = Kleisli {
 runKleisli :: a > m b
 returnA :: Arrow a => a b b
 (^>>) :: Arrow a => (b > c) > a c d > a b d
 (>>^) :: Arrow a => a b c > (c > d) > a b d
 (<<^) :: Arrow a => a c d > (b > c) > a b d
 (^<<) :: Arrow a => (c > d) > a b c > a b d
 class Arrow a => ArrowZero a where
 zeroArrow :: a b c
 class ArrowZero a => ArrowPlus a where
 (<+>) :: a b c > a b c > a b c
 class Arrow a => ArrowChoice a where
 class Arrow a => ArrowApply a where
 app :: a (a b c, b) c
 newtype ArrowApply a => ArrowMonad a b = ArrowMonad (a () b)
 leftApp :: ArrowApply a => a b c > a (Either b d) (Either c d)
 class Arrow a => ArrowLoop a where
 loop :: a (b, d) (c, d) > a b c
 (>>>) :: Category cat => cat a b > cat b c > cat a c
 (<<<) :: Category cat => cat b c > cat a b > cat a c
Arrows
class Category a => Arrow a whereSource
The basic arrow class.
Minimal complete definition: arr
and first
.
The other combinators have sensible default definitions, which may be overridden for efficiency.
arr :: (b > c) > a b cSource
Lift a function to an arrow.
first :: a b c > a (b, d) (c, d)Source
Send the first component of the input through the argument arrow, and copy the rest unchanged to the output.
second :: a b c > a (d, b) (d, c)Source
A mirror image of first
.
The default definition may be overridden with a more efficient version if desired.
(***) :: a b c > a b' c' > a (b, b') (c, c')Source
Split the input between the two argument arrows and combine their output. Note that this is in general not a functor.
The default definition may be overridden with a more efficient version if desired.
(&&&) :: a b c > a b c' > a b (c, c')Source
Fanout: send the input to both argument arrows and combine their output.
The default definition may be overridden with a more efficient version if desired.
Kleisli arrows of a monad.
Kleisli  

Derived combinators
returnA :: Arrow a => a b bSource
The identity arrow, which plays the role of return
in arrow notation.
Righttoleft variants
(<<^) :: Arrow a => a c d > (b > c) > a b dSource
Precomposition with a pure function (righttoleft variant).
(^<<) :: Arrow a => (c > d) > a b c > a b dSource
Postcomposition with a pure function (righttoleft variant).
Monoid operations
Conditionals
class Arrow a => ArrowChoice a whereSource
Choice, for arrows that support it. This class underlies the
if
and case
constructs in arrow notation.
Any instance must define left
. The other combinators have sensible
default definitions, which may be overridden for efficiency.
left :: a b c > a (Either b d) (Either c d)Source
Feed marked inputs through the argument arrow, passing the rest through unchanged to the output.
right :: a b c > a (Either d b) (Either d c)Source
A mirror image of left
.
The default definition may be overridden with a more efficient version if desired.
(+++) :: a b c > a b' c' > a (Either b b') (Either c c')Source
Split the input between the two argument arrows, retagging and merging their outputs. Note that this is in general not a functor.
The default definition may be overridden with a more efficient version if desired.
() :: a b d > a c d > a (Either b c) dSource
Fanin: Split the input between the two argument arrows and merge their outputs.
The default definition may be overridden with a more efficient version if desired.
ArrowChoice (>)  
Monad m => ArrowChoice (Kleisli m) 
Arrow application
class Arrow a => ArrowApply a whereSource
Some arrows allow application of arrow inputs to other inputs.
ArrowApply (>)  
Monad m => ArrowApply (Kleisli m) 
newtype ArrowApply a => ArrowMonad a b Source
The ArrowApply
class is equivalent to Monad
: any monad gives rise
to a Kleisli
arrow, and any instance of ArrowApply
defines a monad.
ArrowMonad (a () b) 
ArrowApply a => Monad (ArrowMonad a) 
leftApp :: ArrowApply a => a b c > a (Either b d) (Either c d)Source
Any instance of ArrowApply
can be made into an instance of
ArrowChoice
by defining left
= leftApp
.