-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | functions for working with arrows -- -- arrow-utils provides useful functions and type classes for working -- with arrows. It provides functions similar to sequenceA. @package arrow-utils @version 0.1.2 module Control.Arrow.Utils -- | 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. newtype SameInputArrow a b c SameInputArrow :: a b c -> SameInputArrow a b c [unSameInputArrow] :: SameInputArrow a b c -> a b c -- | Creates arrows using f, then runs all arrows in the given -- Traversable, collecting the results. -- --
-- traverseArr (+) [1,10] 1 == [2,11] --traverseArr :: (Traversable t, Arrow a) => (x -> a b c) -> t x -> a b (t c) -- | Creates arrows using f, then runs all arrows in the given -- Foldable, discarding the results. traverseArr_ :: (Foldable t, Arrow a) => (x -> a b c) -> t x -> a b () -- | Like sequenceArr, but discard the results. sequenceArr_ :: (Foldable t, Arrow a) => t (a b any) -> a b () -- | Run all arrows in the given Traversable, collecting the -- results. -- --
-- sequenceArr [(+1), (+10)] 1 == [2,11] --sequenceArr :: (Traversable t, Arrow a) => t (a b c) -> a b (t c) -- | 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] --zipSequenceArrVec :: (Arrow a, KnownNat n) => Vector n (a b c) -> a (Vector n b) (Vector n c) -- | 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] --zipSequenceArrList :: (Arrow a, ArrowChoice a) => [a b c] -> a [b] [c] -- | Similar to when for Applicative. -- Relevant for arrows which embeded a Monad. whenArr :: ArrowChoice a => a b () -> a (Bool, b) () -- | Similar to unless for Applicative. -- Relevant for arrows which embeded a Monad. unlessArr :: ArrowChoice a => a b () -> a (Bool, b) () -- | Always output the given value. constantly :: Arrow a => b -> a any b instance Control.Arrow.Arrow a => GHC.Base.Functor (Control.Arrow.Utils.SameInputArrow a b) instance Control.Arrow.Arrow a => GHC.Base.Applicative (Control.Arrow.Utils.SameInputArrow a b)