concatenative-0.0.0: A library for postfix control flow.

Control.Concatenative

Contents

Description

Control.Concatenative brings postfix notation in the style of factor (see http:factorcode.org) to haskell. Interfaces using both combinators and arrows are available.

Synopsis

Postfix combinators

bi :: (a -> b) -> (a -> c) -> (b -> c -> d) -> a -> dSource

Apply both arguments to a and combine the results

tri :: (a -> b) -> (a -> c) -> (a -> d) -> (b -> c -> d -> e) -> a -> eSource

Apply each of three arguments to a and combine the results

biSp :: (a -> c) -> (b -> d) -> (c -> d -> e) -> a -> b -> eSource

Apply the first argument to a, the second to b, and combine the results

triSp :: (a -> d) -> (b -> e) -> (c -> f) -> (d -> e -> f -> g) -> a -> b -> c -> gSource

Apply the first argument to a, the second to b, and the third to c, combining the results

biAp :: (t -> t1) -> (t1 -> t1 -> t2) -> t -> t -> t2Source

Apply a function to two values and combine the results

triAp :: (a -> b) -> (b -> b -> b -> c) -> a -> a -> a -> cSource

Apply a function to three values and combine the results

ifteSource

Arguments

:: (a -> Bool)

A predicate

-> (a -> b)

Applied if the predicate yields True

-> (a -> b)

Applied if the predicate yields False

-> a 
-> b 

Postfix arrows

(>>@) :: Arrow a => a b (x, y) -> (x -> y -> z) -> a b zSource

Combine with a binary function

dup :: Arrow a => a b (b, b)Source

swap :: Arrow a => a (x, y) (y, x)Source

both :: Arrow a => a b c -> a (b, b) (c, c)Source

Arrow version of biAp

(>>>) :: Category cat => cat a b -> cat b c -> cat a c

Left-to-right composition

(&&&) :: Arrow a => forall b c c'. a b c -> a b c' -> a b (c, c')

Fanout: send the input to both argument arrows and combine their output.

The default definition may be overridden with a more efficient version if desired.

(***) :: Arrow a => forall b c b' c'. a b c -> a b' c' -> a (b, b') (c, c')

Split the input between the two argument arrows and combine their output. Note that this is in general not a functor.

The default definition may be overridden with a more efficient version if desired.

first :: Arrow a => forall b c d. a b c -> a (b, d) (c, d)

Send the first component of the input through the argument arrow, and copy the rest unchanged to the output.

second :: Arrow a => forall b c d. a b c -> a (d, b) (d, c)

A mirror image of first.

The default definition may be overridden with a more efficient version if desired.