Safe Haskell | None |
---|---|
Language | Haskell2010 |
Control.Arrow.Utils
Synopsis
- newtype SameInputArrow a b c = SameInputArrow {
- unSameInputArrow :: a b c
- traverseArr :: (Traversable t, Arrow a) => (x -> a b c) -> t x -> a b (t c)
- traverseArr_ :: (Foldable t, Arrow a) => (x -> a b c) -> t x -> a b ()
- sequenceArr_ :: (Foldable t, Arrow a) => t (a b any) -> a b ()
- sequenceArr :: (Traversable t, Arrow a) => t (a b c) -> a b (t c)
- zipSequenceArrVec :: (Arrow a, KnownNat n) => Vector n (a b c) -> a (Vector n b) (Vector n c)
- zipSequenceArrList :: (Arrow a, ArrowChoice a) => [a b c] -> a [b] [c]
- whenArr :: ArrowChoice a => a b () -> a (Bool, b) ()
- unlessArr :: ArrowChoice a => a b () -> a (Bool, b) ()
- constantly :: Arrow a => b -> a any b
Documentation
newtype SameInputArrow a b c Source #
Wrap the Arrow in a newtype in order to create new class instances.
This is a generalisation of ArrowMonad
,
which is isomorphic to
.SameInputArrow
a () c
Constructors
SameInputArrow | |
Fields
|
Instances
Arrow a => Functor (SameInputArrow a b) Source # |
|
Defined in Control.Arrow.Utils Methods fmap :: (a0 -> b0) -> SameInputArrow a b a0 -> SameInputArrow a b b0 # (<$) :: a0 -> SameInputArrow a b b0 -> SameInputArrow a b a0 # | |
Arrow a => Applicative (SameInputArrow a b) Source # |
|
Defined in Control.Arrow.Utils Methods pure :: a0 -> SameInputArrow a b a0 # (<*>) :: SameInputArrow a b (a0 -> b0) -> SameInputArrow a b a0 -> SameInputArrow a b b0 # liftA2 :: (a0 -> b0 -> c) -> SameInputArrow a b a0 -> SameInputArrow a b b0 -> SameInputArrow a b c # (*>) :: SameInputArrow a b a0 -> SameInputArrow a b b0 -> SameInputArrow a b b0 # (<*) :: SameInputArrow a b a0 -> SameInputArrow a b b0 -> SameInputArrow a b a0 # |
traverseArr :: (Traversable t, Arrow a) => (x -> a b c) -> t x -> a b (t c) Source #
Creates arrows using f, then runs all arrows in the given Traversable
,
collecting the results.
traverseArr (+) [1,10] 1 == [2,11]
traverseArr_ :: (Foldable t, Arrow a) => (x -> a b c) -> t x -> a b () Source #
Creates arrows using f, then runs all arrows in the given Foldable
,
discarding the results.
sequenceArr_ :: (Foldable t, Arrow a) => t (a b any) -> a b () Source #
Like sequenceArr
, but discard the results.
sequenceArr :: (Traversable t, Arrow a) => t (a b c) -> a b (t c) Source #
Run all arrows in the given Traversable
, collecting the results.
sequenceArr [(+1), (+10)] 1 == [2,11]
zipSequenceArrVec :: (Arrow a, KnownNat n) => Vector n (a b c) -> a (Vector n b) (Vector n c) Source #
Fans each input from Vector n b
to a separate arrow from the given vector.
sequenceArrVec (Vec.generate ((+).fromIntegral) :: Vector 5 (Int -> Int)) (Vec.replicate 1 :: Vector 5 Int) == Vector [1,2,3,4,5]
zipSequenceArrList :: (Arrow a, ArrowChoice a) => [a b c] -> a [b] [c] Source #
Fans each input from [b]
to a separate arrow from the given list.
The output list has length of the minimum of the input list length and the arrow list length.
sequenceArrList [(+1), (+10)] [1,2] == [2,12] sequenceArrList [(+1), (+10)] [1] == [2] sequenceArrList [(+1)] [1,2,3,4] == [2]
whenArr :: ArrowChoice a => a b () -> a (Bool, b) () Source #
Similar to
for when
. Relevant for
arrows which embeded a Monad.Applicative
unlessArr :: ArrowChoice a => a b () -> a (Bool, b) () Source #
Similar to
for unless
. Relevant for
arrows which embeded a Monad.Applicative
constantly :: Arrow a => b -> a any b Source #
Always output the given value.