Movatterモバイル変換


[0]ホーム

URL:


base-4.12.0.0: Basic libraries

Copyright(c) Ross Paterson 2002
LicenseBSD-style (see the LICENSE file in the distribution)
Maintainerlibraries@haskell.org
Stabilityprovisional
Portabilityportable
Safe HaskellTrustworthy
LanguageHaskell2010

Control.Arrow

Contents

Description

Basic arrow definitions, based on

  • Generalising Monads to Arrows, by John Hughes,Science of Computer Programming 37, pp67-111, May 2000.

plus a couple of definitions (returnA andloop) from

  • A New Notation for Arrows, by Ross Paterson, inICFP 2001, Firenze, Italy, pp229-240.

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

Synopsis

Arrows

classCategory a =>Arrow awhereSource#

The basic arrow class.

Instances should satisfy the following laws:

where

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

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

Minimal complete definition

arr, (first |(***))

Methods

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 offirst.

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 3Source#

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 3Source#

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.

Instances
Monad m =>Arrow (Kleisli m)Source#

Since: 2.1

Instance details

Defined inControl.Arrow

Methods

arr :: (b -> c) ->Kleisli m b cSource#

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#

Arrow ((->) ::Type ->Type ->Type)Source#

Since: 2.1

Instance details

Defined inControl.Arrow

Methods

arr :: (b -> c) -> b -> cSource#

first :: (b -> c) -> (b, d) -> (c, d)Source#

second :: (b -> c) -> (d, b) -> (d, c)Source#

(***) :: (b -> c) -> (b' -> c') -> (b, b') -> (c, c')Source#

(&&&) :: (b -> c) -> (b -> c') -> b -> (c, c')Source#

newtypeKleisli m a bSource#

Kleisli arrows of a monad.

Constructors

Kleisli 

Fields

Instances
MonadFix m =>ArrowLoop (Kleisli m)Source#

Beware that for many monads (those for which the>>= operation is strict) this instance willnot satisfy the right-tightening law required by theArrowLoop class.

Since: 2.1

Instance details

Defined inControl.Arrow

Methods

loop ::Kleisli m (b, d) (c, d) ->Kleisli m b cSource#

Monad m =>ArrowApply (Kleisli m)Source#

Since: 2.1

Instance details

Defined inControl.Arrow

Methods

app ::Kleisli m (Kleisli m b c, b) cSource#

Monad m =>ArrowChoice (Kleisli m)Source#

Since: 2.1

Instance details

Defined inControl.Arrow

Methods

left ::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#

(|||) ::Kleisli m b d ->Kleisli m c d ->Kleisli m (Either b c) dSource#

MonadPlus m =>ArrowPlus (Kleisli m)Source#

Since: 2.1

Instance details

Defined inControl.Arrow

Methods

(<+>) ::Kleisli m b c ->Kleisli m b c ->Kleisli m b cSource#

MonadPlus m =>ArrowZero (Kleisli m)Source#

Since: 2.1

Instance details

Defined inControl.Arrow

Methods

zeroArrow ::Kleisli m b cSource#

Monad m =>Arrow (Kleisli m)Source#

Since: 2.1

Instance details

Defined inControl.Arrow

Methods

arr :: (b -> c) ->Kleisli m b cSource#

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 =>Category (Kleisli m ::Type ->Type ->Type)Source#

Since: 3.0

Instance details

Defined inControl.Arrow

Methods

id ::Kleisli m a aSource#

(.) ::Kleisli m b c ->Kleisli m a b ->Kleisli m a cSource#

Derived combinators

returnA ::Arrow a => a b bSource#

The identity arrow, which plays the role ofreturn in arrow notation.

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

Precomposition with a pure function.

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

Postcomposition with a pure function.

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

Left-to-right composition

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

Right-to-left composition

Right-to-left variants

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

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

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

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

Monoid operations

classArrow a =>ArrowZero awhereSource#

Methods

zeroArrow :: a b cSource#

Instances
MonadPlus m =>ArrowZero (Kleisli m)Source#

Since: 2.1

Instance details

Defined inControl.Arrow

Methods

zeroArrow ::Kleisli m b cSource#

classArrowZero a =>ArrowPlus awhereSource#

A monoid on arrows.

Methods

(<+>) :: a b c -> a b c -> a b cinfixr 5Source#

An associative operation with identityzeroArrow.

Instances
MonadPlus m =>ArrowPlus (Kleisli m)Source#

Since: 2.1

Instance details

Defined inControl.Arrow

Methods

(<+>) ::Kleisli m b c ->Kleisli m b c ->Kleisli m b cSource#

Conditionals

classArrow a =>ArrowChoice awhereSource#

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

Instances should satisfy the following laws:

where

assocsum (Left (Left x)) = Left xassocsum (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.

Minimal complete definition

(left |(+++))

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 ofleft.

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 2Source#

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) dinfixr 2Source#

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
Monad m =>ArrowChoice (Kleisli m)Source#

Since: 2.1

Instance details

Defined inControl.Arrow

Methods

left ::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#

(|||) ::Kleisli m b d ->Kleisli m c d ->Kleisli m (Either b c) dSource#

ArrowChoice ((->) ::Type ->Type ->Type)Source#

Since: 2.1

Instance details

Defined inControl.Arrow

Methods

left :: (b -> c) ->Either b d ->Either c dSource#

right :: (b -> c) ->Either d b ->Either d cSource#

(+++) :: (b -> c) -> (b' -> c') ->Either b b' ->Either c c'Source#

(|||) :: (b -> d) -> (c -> d) ->Either b c -> dSource#

Arrow application

classArrow a =>ArrowApply awhereSource#

Some arrows allow application of arrow inputs to other inputs. Instances should satisfy the following laws:

Such arrows are equivalent to monads (seeArrowMonad).

Methods

app :: a (a b c, b) cSource#

Instances
Monad m =>ArrowApply (Kleisli m)Source#

Since: 2.1

Instance details

Defined inControl.Arrow

Methods

app ::Kleisli m (Kleisli m b c, b) cSource#

ArrowApply ((->) ::Type ->Type ->Type)Source#

Since: 2.1

Instance details

Defined inControl.Arrow

Methods

app :: (b -> c, b) -> cSource#

newtypeArrowMonad a bSource#

TheArrowApply class is equivalent toMonad: any monad gives rise to aKleisli arrow, and any instance ofArrowApply defines a monad.

Constructors

ArrowMonad (a () b) 
Instances
ArrowApply a =>Monad (ArrowMonad a)Source#

Since: 2.1

Instance details

Defined inControl.Arrow

Arrow a =>Functor (ArrowMonad a)Source#

Since: 4.6.0.0

Instance details

Defined inControl.Arrow

Methods

fmap :: (a0 -> b) ->ArrowMonad a a0 ->ArrowMonad a bSource#

(<$) :: a0 ->ArrowMonad a b ->ArrowMonad a a0Source#

Arrow a =>Applicative (ArrowMonad a)Source#

Since: 4.6.0.0

Instance details

Defined inControl.Arrow

Methods

pure :: a0 ->ArrowMonad a a0Source#

(<*>) ::ArrowMonad a (a0 -> b) ->ArrowMonad a a0 ->ArrowMonad a bSource#

liftA2 :: (a0 -> b -> c) ->ArrowMonad a a0 ->ArrowMonad a b ->ArrowMonad a cSource#

(*>) ::ArrowMonad a a0 ->ArrowMonad a b ->ArrowMonad a bSource#

(<*) ::ArrowMonad a a0 ->ArrowMonad a b ->ArrowMonad a a0Source#

(ArrowApply a,ArrowPlus a) =>MonadPlus (ArrowMonad a)Source#

Since: 4.6.0.0

Instance details

Defined inControl.Arrow

ArrowPlus a =>Alternative (ArrowMonad a)Source#

Since: 4.6.0.0

Instance details

Defined inControl.Arrow

leftApp ::ArrowApply a => a b c -> a (Either b d) (Either c d)Source#

Any instance ofArrowApply can be made into an instance ofArrowChoice by definingleft =leftApp.

Feedback

classArrow a =>ArrowLoop awhereSource#

Theloop operator expresses computations in which an output value is fed back as input, although the computation occurs only once. It underlies therec value recursion construct in arrow notation.loop should satisfy the following laws:

extension
loop (arr f) =arr (\ b ->fst (fix (\ (c,d) -> f (b,d))))
left tightening
loop (first h >>> f) = h >>>loop f
right tightening
loop (f >>>first h) =loop f >>> h
sliding
loop (f >>>arr (id *** k)) =loop (arr (id *** k) >>> f)
vanishing
loop (loop f) =loop (arr unassoc >>> f >>>arr assoc)
superposing
second (loop f) =loop (arr assoc >>>second f >>>arr unassoc)

where

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

Methods

loop :: a (b, d) (c, d) -> a b cSource#

Instances
MonadFix m =>ArrowLoop (Kleisli m)Source#

Beware that for many monads (those for which the>>= operation is strict) this instance willnot satisfy the right-tightening law required by theArrowLoop class.

Since: 2.1

Instance details

Defined inControl.Arrow

Methods

loop ::Kleisli m (b, d) (c, d) ->Kleisli m b cSource#

ArrowLoop ((->) ::Type ->Type ->Type)Source#

Since: 2.1

Instance details

Defined inControl.Arrow

Methods

loop :: ((b, d) -> (c, d)) -> b -> cSource#

Produced byHaddock version 2.20.0


[8]ページ先頭

©2009-2025 Movatter.jp