Control.Arrow (original) (raw)

Contents

Description

Basic arrow definitions, based on

plus a couple of definitions ([returnA](Control-Arrow.html#v:returnA "Control.Arrow") and [loop](Control-Arrow.html#v:loop "Control.Arrow")) from

These papers and more information on arrows can be found athttp://www.haskell.org/arrows/.

Synopsis

Arrows

class Category a => Arrow a where Source #

Methods

arr :: (b -> c) -> a b c Source #

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](Control-Arrow.html#v:first "Control.Arrow").

The default definition may be overridden with a more efficient version if desired.

(***) :: a b c -> a b' c' -> a (b, b') (c, c') infixr 3 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') infixr 3 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.

newtype Kleisli m a b Source #

Kleisli arrows of a monad.

Instances

Instances details

Monad m => Category (Kleisli m :: Type -> Type -> TYPE LiftedRep) Source # Since: base-3.0
Instance detailsDefined in Control.Arrow Methodsid :: forall (a :: k). Kleisli m a a Source #(.) :: forall (b :: k) (c :: k) (a :: k). Kleisli m b c -> Kleisli m a b -> Kleisli m a c Source #
Generic1 (Kleisli m a :: Type -> TYPE LiftedRep) Source #
Instance detailsDefined in Control.Arrow Associated Typestype Rep1 (Kleisli m a) :: k -> Type Source # Methodsfrom1 :: forall (a0 :: k). Kleisli m a a0 -> Rep1 (Kleisli m a) a0 Source #to1 :: forall (a0 :: k). Rep1 (Kleisli m a) a0 -> Kleisli m a a0 Source #
Monad m => Arrow (Kleisli m) Source # Since: base-2.1
Instance detailsDefined in Control.Arrow Methodsarr :: (b -> c) -> Kleisli m b c Source #first :: Kleisli m b c -> Kleisli m (b, d) (c, d) Source #second :: Kleisli m b c -> Kleisli m (d, b) (d, c) Source #(***) :: Kleisli m b c -> Kleisli m b' c' -> Kleisli m (b, b') (c, c') Source #(&&&) :: Kleisli m b c -> Kleisli m b c' -> Kleisli m b (c, c') Source #
Monad m => ArrowApply (Kleisli m) Source # Since: base-2.1
Instance detailsDefined in Control.Arrow Methodsapp :: Kleisli m (Kleisli m b c, b) c Source #
Monad m => ArrowChoice (Kleisli m) Source # Since: base-2.1
Instance detailsDefined in Control.Arrow Methodsleft :: Kleisli m b c -> Kleisli m (Either b d) (Either c d) Source #right :: Kleisli m b c -> Kleisli m (Either d b) (Either d c) Source #(+++) :: Kleisli m b c -> Kleisli m b' c' -> Kleisli m (Either b b') (Either c c') Source #[(|
MonadFix m => ArrowLoop (Kleisli m) Source # Beware that for many monads (those for which the >>= operation is strict) this instance will not satisfy the right-tightening law required by the ArrowLoop class.Since: base-2.1
Instance detailsDefined in Control.Arrow Methodsloop :: Kleisli m (b, d) (c, d) -> Kleisli m b c Source #
MonadPlus m => ArrowPlus (Kleisli m) Source # Since: base-2.1
Instance detailsDefined in Control.Arrow Methods(<+>) :: Kleisli m b c -> Kleisli m b c -> Kleisli m b c Source #
MonadPlus m => ArrowZero (Kleisli m) Source # Since: base-2.1
Instance detailsDefined in Control.Arrow MethodszeroArrow :: Kleisli m b c Source #
Alternative m => Alternative (Kleisli m a) Source # Since: base-4.14.0.0
Instance detailsDefined in Control.Arrow Methodsempty :: Kleisli m a a0 Source #(<|>) :: Kleisli m a a0 -> Kleisli m a a0 -> Kleisli m a a0 Source #some :: Kleisli m a a0 -> Kleisli m a [a0] Source #many :: Kleisli m a a0 -> Kleisli m a [a0] Source #
Applicative m => Applicative (Kleisli m a) Source # Since: base-4.14.0.0
Instance detailsDefined in Control.Arrow Methodspure :: a0 -> Kleisli m a a0 Source #(<*>) :: Kleisli m a (a0 -> b) -> Kleisli m a a0 -> Kleisli m a b Source #liftA2 :: (a0 -> b -> c) -> Kleisli m a a0 -> Kleisli m a b -> Kleisli m a c Source #(*>) :: Kleisli m a a0 -> Kleisli m a b -> Kleisli m a b Source #(<*) :: Kleisli m a a0 -> Kleisli m a b -> Kleisli m a a0 Source #
Functor m => Functor (Kleisli m a) Source # Since: base-4.14.0.0
Instance detailsDefined in Control.Arrow Methodsfmap :: (a0 -> b) -> Kleisli m a a0 -> Kleisli m a b Source #(<$) :: a0 -> Kleisli m a b -> Kleisli m a a0 Source #
Monad m => Monad (Kleisli m a) Source # Since: base-4.14.0.0
Instance detailsDefined in Control.Arrow Methods(>>=) :: Kleisli m a a0 -> (a0 -> Kleisli m a b) -> Kleisli m a b Source #(>>) :: Kleisli m a a0 -> Kleisli m a b -> Kleisli m a b Source #return :: a0 -> Kleisli m a a0 Source #
MonadPlus m => MonadPlus (Kleisli m a) Source # Since: base-4.14.0.0
Instance detailsDefined in Control.Arrow Methodsmzero :: Kleisli m a a0 Source #mplus :: Kleisli m a a0 -> Kleisli m a a0 -> Kleisli m a a0 Source #
Generic (Kleisli m a b) Source #
Instance detailsDefined in Control.Arrow Associated Typestype Rep (Kleisli m a b) :: Type -> Type Source # Methodsfrom :: Kleisli m a b -> Rep (Kleisli m a b) x Source #to :: Rep (Kleisli m a b) x -> Kleisli m a b Source #
type Rep1 (Kleisli m a :: Type -> TYPE LiftedRep) Source # Since: base-4.14.0.0
Instance detailsDefined in Control.Arrow type Rep1 (Kleisli m a :: Type -> TYPE LiftedRep) = D1 ('MetaData "Kleisli" "Control.Arrow" "base" 'True) (C1 ('MetaCons "Kleisli" 'PrefixI 'True) (S1 ('MetaSel ('Just "runKleisli") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) ((FUN 'Many a :: TYPE LiftedRep -> Type) :.: Rec1 m)))
type Rep (Kleisli m a b) Source # Since: base-4.14.0.0
Instance detailsDefined in Control.Arrow type Rep (Kleisli m a b) = D1 ('MetaData "Kleisli" "Control.Arrow" "base" 'True) (C1 ('MetaCons "Kleisli" 'PrefixI 'True) (S1 ('MetaSel ('Just "runKleisli") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (a -> m b))))

Derived combinators

(^>>) :: Arrow a => (b -> c) -> a c d -> a b d infixr 1 Source #

Precomposition with a pure function.

(>>^) :: Arrow a => a b c -> (c -> d) -> a b d infixr 1 Source #

Postcomposition with a pure function.

(>>>) :: Category cat => cat a b -> cat b c -> cat a c infixr 1 Source #

Left-to-right composition

(<<<) :: Category cat => cat b c -> cat a b -> cat a c infixr 1 Source #

Right-to-left composition

Right-to-left variants

(<<^) :: Arrow a => a c d -> (b -> c) -> a b d infixr 1 Source #

Precomposition with a pure function (right-to-left variant).

(^<<) :: Arrow a => (c -> d) -> a b c -> a b d infixr 1 Source #

Postcomposition with a pure function (right-to-left variant).

Monoid operationsConditionals

class Arrow a => ArrowChoice a where Source #

Choice, for arrows that support it. This class underlies theif and case constructs in arrow notation.

Instances should satisfy the following laws:

where

assocsum (Left (Left x)) = Left x assocsum (Left (Right y)) = Right (Left y) assocsum (Right z) = Right (Right z)

The other combinators have sensible default definitions, which may be overridden for efficiency.

Methods

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](Control-Arrow.html#v:left "Control.Arrow").

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') infixr 2 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) d infixr 2 Source #

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.

Instances

Instances details

Arrow applicationFeedback

class Arrow a => ArrowLoop a where Source #

The [loop](Control-Arrow.html#v:loop "Control.Arrow") operator expresses computations in which an output value is fed back as input, although the computation occurs only once. It underlies the rec value recursion construct in arrow notation.[loop](Control-Arrow.html#v:loop "Control.Arrow") should satisfy the following laws:

extension

`[loop](Control-Arrow.html#v:loop "Control.Arrow")` (`[arr](Control-Arrow.html#v:arr "Control.Arrow")` f) = `[arr](Control-Arrow.html#v:arr "Control.Arrow")` (\ b -> `[fst](Data-Tuple.html#v:fst "Data.Tuple")` (`[fix](Control-Monad-Fix.html#v:fix "Control.Monad.Fix")` (\ (c,d) -> f (b,d))))

left tightening

`[loop](Control-Arrow.html#v:loop "Control.Arrow")` (`[first](Control-Arrow.html#v:first "Control.Arrow")` h >>> f) = h >>> `[loop](Control-Arrow.html#v:loop "Control.Arrow")` f

right tightening

`[loop](Control-Arrow.html#v:loop "Control.Arrow")` (f >>> `[first](Control-Arrow.html#v:first "Control.Arrow")` h) = `[loop](Control-Arrow.html#v:loop "Control.Arrow")` f >>> h

sliding

`[loop](Control-Arrow.html#v:loop "Control.Arrow")` (f >>> `[arr](Control-Arrow.html#v:arr "Control.Arrow")` (`[id](Control-Category.html#v:id "Control.Category")` *** k)) = `[loop](Control-Arrow.html#v:loop "Control.Arrow")` (`[arr](Control-Arrow.html#v:arr "Control.Arrow")` (`[id](Control-Category.html#v:id "Control.Category")` *** k) >>> f)

vanishing

`[loop](Control-Arrow.html#v:loop "Control.Arrow")` (`[loop](Control-Arrow.html#v:loop "Control.Arrow")` f) = `[loop](Control-Arrow.html#v:loop "Control.Arrow")` (`[arr](Control-Arrow.html#v:arr "Control.Arrow")` unassoc >>> f >>> `[arr](Control-Arrow.html#v:arr "Control.Arrow")` assoc)

superposing

`[second](Control-Arrow.html#v:second "Control.Arrow")` (`[loop](Control-Arrow.html#v:loop "Control.Arrow")` f) = `[loop](Control-Arrow.html#v:loop "Control.Arrow")` (`[arr](Control-Arrow.html#v:arr "Control.Arrow")` assoc >>> `[second](Control-Arrow.html#v:second "Control.Arrow")` f >>> `[arr](Control-Arrow.html#v:arr "Control.Arrow")` unassoc)

where

assoc ((a,b),c) = (a,(b,c)) unassoc (a,(b,c)) = ((a,b),c)

Instances

Instances details