arrow-list-0.6: List arrows for Haskell.

Safe HaskellSafe-Infered

Control.Arrow.ArrowF

Contents

Synopsis

Container arrow type class.

class Arrow ~> => ArrowF f (~>) | ~> -> f whereSource

A type class for arrows that produce containers of results. The container arrow can be seen as a generalization for list arrows. Most operations assume the container type has an Applicative, an Alternative and a Foldable instance.

Methods

embedSource

Arguments

:: f a ~> a

Use a container as the input for an arrow.

observeSource

Arguments

:: (a ~> b) 
-> a ~> f b

Get the result as container.

Instances

Monad m => ArrowF [] (ListTArrow m) 
Monad m => ArrowF Seq (SeqTArrow m) 

mapF :: ArrowF f ~> => (f b -> f c) -> (a ~> b) -> a ~> cSource

Map a function over the result collection of a container arrow.

arrMF :: (ArrowF f ~>, ArrowKleisli m ~>) => (a -> m (f c)) -> a ~> cSource

Embed a monadic function returning an ordered list into a container arrow.

Generic arrow utilities.

unite :: ArrowPlus ~> => (b, b) ~> bSource

Take the output of an arrow producing two results and concatenate them into the result of the container arrow.

const :: Arrow ~> => b -> a ~> bSource

Skip the input and produce a constant output.

concatA :: ArrowPlus ~> => [a ~> b] -> a ~> bSource

Collect the results of applying multiple arrows to the same input.

plus :: (Alternative f, ArrowF f ~>) => (a ~> b) -> (a ~> b) -> a ~> bSource

Join the results of two arrows, like (+) from ArrowPlus.

Container arrow utilities.

constF :: ArrowF f ~> => f c -> a ~> cSource

Skip the input and produce a constant output specified as a container.

none :: (Alternative f, ArrowF f ~>) => a ~> bSource

Ignore the input and produce no results. Like zeroArrow.

results :: (Foldable f, ArrowF f ~>) => (a ~> b) -> a ~> BoolSource

Returns a Bool indicating whether the input arrow produces a container with any results.

Conditional and filter arrows.

isA :: (Alternative f, ArrowF f ~>) => (a -> Bool) -> a ~> aSource

Create a filtering container arrow by mapping a predicate function over the input. When the predicate returns True the input will be returned in the output container, when False the empty container is returned.

ifA :: (Foldable f, ArrowF f ~>, ArrowChoice ~>) => (a ~> b) -> (a ~> t) -> (a ~> t) -> a ~> tSource

Use the result of a container arrow as a conditional, like an if-then-else arrow. When the first arrow produces any results the then arrow will be used, when the first arrow produces no results the else arrow will be used.

when :: (Foldable f, ArrowF f ~>, ArrowChoice ~>) => (a ~> a) -> (a ~> c) -> a ~> aSource

Apply a container arrow only when a conditional arrow produces any results. When the conditional produces no results the output arrow /behaves like the identity. The second/ input arrow is used as the conditional, this allow you to write: a `when` condition

guards :: (Alternative f, Foldable f, ArrowF f ~>, ArrowChoice ~>) => (a ~> c) -> (a ~> b) -> a ~> bSource

Apply a container arrow only when a conditional arrow produces any results. When the conditional produces no results the output arrow produces no results. The first input arrow is used as the conditional, this allow you to write: condition `guards` a

filterA :: (Alternative f, Foldable f, ArrowF f ~>, ArrowChoice ~>) => (a ~> c) -> a ~> aSource

Filter the results of an arrow with a predicate arrow, when the filter condition produces results the input is accepted otherwise it is excluded.

notA :: (Alternative f, Foldable f, ArrowF f ~>, ArrowChoice ~>) => (a ~> c) -> a ~> aSource

Negation container arrow. Only accept the input when the condition produces no output.

orElse :: (Foldable f, ArrowF f ~>, ArrowChoice ~>) => (a ~> b) -> (a ~> b) -> a ~> bSource

Apply the input arrow, when the arrow does not produces any results the second fallback arrow is applied. Likely written infix like this a `orElse` b

Optionality.

maybeA :: (Alternative f, ArrowF f ~>) => Maybe a ~> aSource

Map a Maybe input to a container output. When the Maybe is a Nothing an empty container will be returned, Just will result in a singleton container.

optional :: (Foldable f, ArrowF f ~>, ArrowChoice ~>) => (a ~> b) -> a ~> Maybe bSource

Apply a container arrow, when there are no results a Nothing will be returned, otherwise the results will be wrapped in a Just. This function always produces result.