arrow-utils-0.1.0.0: functions for working with arrows
Safe HaskellNone
LanguageHaskell2010

Control.Arrow.Utils

Synopsis

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

Instances details
Arrow a => Functor (SameInputArrow a b) Source #

fmap f postcomposes with f

Instance details

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 #

<*> runs the arrows in parallel

Instance details

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 when for Applicative. Relevant for arrows which embeded a Monad.

unlessArr :: ArrowChoice a => a b () -> a (Bool, b) () Source #

Similar to unless for Applicative. Relevant for arrows which embeded a Monad.

constantly :: Arrow a => b -> a any b Source #

Always output the given value.