arrow-list-0.2.0: List arrows for Haskell.

Control.Arrow.ArrowList

Contents

Description

The ArrowList type class, and a collection of list arrow related functions. This typeclass can be used to embed functions producing multiple outputs into a an arrow.

Synopsis

ArrowList type class.

class Arrow ~> => ArrowList (~>) whereSource

The ArrowList class represents two possible actions:

  1. Lifting functions from one value to a list of values into a list arrow.
  2. Mapping a function over the result list of a list arrow.

Methods

arrL :: (a -> [b]) -> a ~> bSource

mapL :: ([b] -> [c]) -> (a ~> b) -> a ~> cSource

Instances

Creating list arrows.

unlist :: ArrowList ~> => [b] ~> bSource

Create a list arrow of an input list.

unite :: ArrowList ~> => (a ~> (b, b)) -> a ~> bSource

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

none :: ArrowList ~> => a ~> bSource

Ignore the input and produce no results. Like zeroArrow.

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

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

Collecting the results.

list :: ArrowList ~> => (a ~> b) -> a ~> [b]Source

Collect the entire results of an list arrow as a singleton value in the result list.

empty :: ArrowList ~> => (a ~> b) -> a ~> BoolSource

Returns a Bool indicating whether the input arrow produce any results.

Conditional and filter arrows.

isA :: ArrowList ~> => (a -> Bool) -> a ~> aSource

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

ifASource

Arguments

:: (ArrowList ~>, ArrowChoice ~>) 
=> (a ~> c)

Arrow used as condition.

-> (a ~> b)

Arrow to use when condition has results.

-> (a ~> b)

Arrow to use when condition has no results.

-> a ~> b 

Use the result a list 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.

whenSource

Arguments

:: (ArrowList ~>, ArrowChoice ~>) 
=> (a ~> a)

The arrow to apply,

-> (a ~> b)

when this conditional holds.

-> a ~> a 

Apply a list 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` c

guardsSource

Arguments

:: (ArrowList ~>, ArrowChoice ~>) 
=> (a ~> c)

When this condition holds,

-> (a ~> b)

then apply this arrow.

-> a ~> b 

Apply a list 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: c `guards` a

filterA :: (ArrowChoice ~>, ArrowList ~>) => (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 :: (ArrowList ~>, ArrowChoice ~>) => (a ~> c) -> a ~> aSource

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

orElse :: (ArrowList ~>, 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.

maybeL :: ArrowList ~> => Maybe a ~> aSource

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

optional :: (ArrowChoice ~>, ArrowList ~>) => (a ~> b) -> a ~> Maybe bSource

Apply a list 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.