Precomposition with a pure function (right-to-left variant).
Modulehxt-9.3.1.22Haskell2010
Control.Arrow.ListArrows
Module for importing all list arrows
- 2 types
- 6 classes
- 8 values
- Packagehxt-9.3.1.22
- Exports16
- LanguageHaskell2010
- LicenceMIT
- SourceListArrows.hs
Postcomposition with a pure function.
Postcomposition with a pure function (right-to-left variant).
Precomposition with a pure function.
Any instance of ArrowApply can be made into an instance of ArrowChoice by defining left = leftApp.
The identity arrow, which plays the role of return in arrow notation.
b
>───>Right-to-left composition. This is a synonym for (.), but it can be useful to make
the order of composition more apparent.
Left-to-right composition. This is useful if you want to write a morphism as a pipeline going from left to right.
The basic arrow class.
Instances should satisfy the following laws:
arr id = idarr (f >>> g) = arr f >>> arr gfirst (arr f) = arr (first f)first (f >>> g) = first f >>> first gfirst f >>> arrfst= arrfst>>> ffirst f >>> arr (id *** g) = arr (id *** g) >>> first ffirst (first f) >>> arr assoc = arr assoc >>> first f
where
assoc ((a,b),c) = (a,(b,c))The other combinators have sensible default definitions, which may be overridden for efficiency.
Methods
arr :: (b -> c) -> a b cLift a function to an arrow.
b ╭───╮ c >───┤ f ├───> ╰───╯first :: a b c -> a (b, d) (c, d)Send the first component of the input through the argument arrow, and copy the rest unchanged to the output.
The default definition may be overridden with a more efficient version if desired.
b ╭─────╮ c >───┼─ f ─┼───> >───┼─────┼───> d ╰─────╯ dsecond :: a b c -> a (d, b) (d, c)Send the second component of the input through the argument arrow, and copy the rest unchanged to the output.
The default definition may be overridden with a more efficient version if desired.
d ╭─────╮ d >───┼─────┼───> >───┼─ f ─┼───> b ╰─────╯ c(***) :: a b c -> a b' c' -> a (b, b') (c, c')infixr 3Split 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.
b ╭─────╮ c >───┼─ f ─┼───> >───┼─ g ─┼───> b'╰─────╯ c'(&&&) :: a b c -> a b c' -> a b (c, c')infixr 3Fanout: send the input to both argument arrows and combine their output.
The default definition may be overridden with a more efficient version if desired.
╭───────╮ c b │ ┌─ f ─┼───> >───┼─┤ │ │ └─ g ─┼───> ╰───────╯ c'
Instances6Arrow
Arrow IOLADefined in hxt-9.3.1.22 · Control.Arrow.IOListArrowArrow LADefined in hxt-9.3.1.22 · Control.Arrow.ListArrowMonad m => Arrow (Kleisli m)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowArrow (IOSLA s)Defined in hxt-9.3.1.22 · Control.Arrow.IOStateListArrowArrow (SLA s)Defined in hxt-9.3.1.22 · Control.Arrow.StateListArrowArrow (->)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Arrow
Some arrows allow application of arrow inputs to other inputs. Instances should satisfy the following laws:
first (arr (\x -> arr (\y -> (x,y)))) >>> app = idfirst (arr (g >>>)) >>> app = second g >>> appfirst (arr (>>> h)) >>> app = app >>> h
Such arrows are equivalent to monads (see ArrowMonad).
Methods
app :: a (a b c, b) c
Instances6ArrowApply
ArrowApply IOLADefined in hxt-9.3.1.22 · Control.Arrow.IOListArrowArrowApply LADefined in hxt-9.3.1.22 · Control.Arrow.ListArrowMonad m => ArrowApply (Kleisli m)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowArrowApply (IOSLA s)Defined in hxt-9.3.1.22 · Control.Arrow.IOStateListArrowArrowApply (SLA s)Defined in hxt-9.3.1.22 · Control.Arrow.StateListArrowArrowApply (->)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Arrow
Choice, for arrows that support it. This class underlies the
if and case constructs in arrow notation.
Instances should satisfy the following laws:
left (arr f) = arr (left f)left (f >>> g) = left f >>> left gf >>> arr Left = arr Left >>> left fleft f >>> arr (id +++ g) = arr (id +++ g) >>> left fleft (left f) >>> arr assocsum = arr assocsum >>> left f
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)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)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')infixr 2Split 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 2Fanin: 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.
Instances6ArrowChoice
ArrowChoice IOLADefined in hxt-9.3.1.22 · Control.Arrow.IOListArrowArrowChoice LADefined in hxt-9.3.1.22 · Control.Arrow.ListArrowMonad m => ArrowChoice (Kleisli m)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowArrowChoice (IOSLA s)Defined in hxt-9.3.1.22 · Control.Arrow.IOStateListArrowArrowChoice (SLA s)Defined in hxt-9.3.1.22 · Control.Arrow.StateListArrowArrowChoice (->)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Arrow
The ArrowApply class is equivalent to Monad: any monad gives rise to a Kleisli arrow, and any instance of ArrowApply defines a monad.
Constructors
ArrowMonad (a () b)
Instances5Monad, Functor, Applicative, Alternative, MonadPlus
ArrowApply a => Monad (ArrowMonad a)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowArrow a => Functor (ArrowMonad a)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowArrow a => Applicative (ArrowMonad a)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowArrowPlus a => Alternative (ArrowMonad a)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Arrow(ArrowApply a, ArrowPlus a) => MonadPlus (ArrowMonad a)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Arrow
A monoid on arrows.
Instances5ArrowPlus
ArrowPlus IOLADefined in hxt-9.3.1.22 · Control.Arrow.IOListArrowArrowPlus LADefined in hxt-9.3.1.22 · Control.Arrow.ListArrowMonadPlus m => ArrowPlus (Kleisli m)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowArrowPlus (IOSLA s)Defined in hxt-9.3.1.22 · Control.Arrow.IOStateListArrowArrowPlus (SLA s)Defined in hxt-9.3.1.22 · Control.Arrow.StateListArrow
Methods
zeroArrow :: a b c
Instances5ArrowZero
ArrowZero IOLADefined in hxt-9.3.1.22 · Control.Arrow.IOListArrowArrowZero LADefined in hxt-9.3.1.22 · Control.Arrow.ListArrowMonadPlus m => ArrowZero (Kleisli m)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowArrowZero (IOSLA s)Defined in hxt-9.3.1.22 · Control.Arrow.IOStateListArrowArrowZero (SLA s)Defined in hxt-9.3.1.22 · Control.Arrow.StateListArrow
Kleisli arrows of a monad.
Constructors
KleislirunKleisli :: a -> m b
Instances16Category, Generic1, Arrow, ArrowApply, ArrowChoice, ArrowPlus, …
Monad m => Category (Kleisli m)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowGeneric1 (Kleisli m a)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowMonad m => Arrow (Kleisli m)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowMonad m => ArrowApply (Kleisli m)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowMonad m => ArrowChoice (Kleisli m)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowMonadPlus m => ArrowPlus (Kleisli m)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowMonadPlus m => ArrowZero (Kleisli m)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowMonadFix m => ArrowLoop (Kleisli m)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.FixBeware 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.Monad m => Monad (Kleisli m a)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowFunctor m => Functor (Kleisli m a)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowApplicative m => Applicative (Kleisli m a)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowAlternative m => Alternative (Kleisli m a)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowMonadPlus m => MonadPlus (Kleisli m a)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.ArrowGeneric (Kleisli m a b)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Arrowtype Rep (Kleisli m a b) = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Control.Arrow"Kleisli"
"GHC.Internal.Control.Arrow"
"ghc-internal"
'True) (C1 ('MetaCons"Kleisli"
'PrefixI 'True) (S1 ('MetaSel ('Just"runKleisli"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (a -> m b))))type Rep1 (Kleisli m a) = D1 ('MetaDataDefined in ghc-internal-10.0.0 · GHC.Internal.Control.Arrow"Kleisli"
"GHC.Internal.Control.Arrow"
"ghc-internal"
'True) (C1 ('MetaCons"Kleisli"
'PrefixI 'True) (S1 ('MetaSel ('Just"runKleisli"
) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (FUN 'Many a :.: Rec1 m)))
The loop 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 should satisfy the following laws:
- extension
- left tightening
- right tightening
- sliding
- vanishing
- 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 c╭──────────────╮ b │ ╭───╮ │ c >───┼─────┤ ├────┼───> │ ┌─┤ ├─┐ │ │ d │ ╰───╯ │ │ │ └───<───┘ │ ╰──────────────╯
Instances2ArrowLoop
MonadFix m => ArrowLoop (Kleisli m)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.FixBeware 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.ArrowLoop (->)Defined in ghc-internal-10.0.0 · GHC.Internal.Control.Monad.Fix
module Control.Arrow.ArrowExc
module Control.Arrow.ArrowIf
module Control.Arrow.ArrowIO
module Control.Arrow.ArrowList
module Control.Arrow.ArrowNF
module Control.Arrow.ArrowState
module Control.Arrow.ArrowTree
module Control.Arrow.ListArrow
module Control.Arrow.StateListArrow
module Control.Arrow.IOListArrow
module Control.Arrow.NTreeEdit