Data.Thrist

Synopsis

# Types:

data Thrist whereSource

A type-threaded list of binary polymorphic types.

Constructors

 Nil :: Thrist ~> a a Cons :: (a ~> b) -> Thrist ~> b c -> Thrist ~> a c

Instances

 Arrow ~> => Arrow (Thrist ~>) Category (Thrist ~>) Monoid (Thrist ~> a a)

newtype Flipped m a b Source

A newtype wrapper, defined for convenience, that swaps the two type variables of a binary type. Can be used to reverse a Thrist using foldlThrist. See examples.

Constructors

 Flipped Fieldsunflip :: m b a

# Fold and map functions:

mapThrist :: (forall i j. (i +> j) -> i ~> j) -> Thrist +> a b -> Thrist ~> a bSource

Equivalent to map for thrists. Takes a function from one binary type to another and applies it to each thrist element. For example this could convert a thrist of (a,b) into a thrist of Either a b:

foldrThrist :: (forall i j. (i ~> j) -> (j +> c) -> i +> c) -> (b +> c) -> Thrist ~> a b -> a +> cSource

Equivalent to foldr for thrists. Takes a combining function, a value to replace Nil, and a thrist, returning some new binary type.

foldlThrist :: (forall j k. (a +> j) -> (j ~> k) -> a +> k) -> (a +> b) -> Thrist ~> b c -> a +> cSource

Equivalent to foldl for Thrists.

foldr1Thrist :: (forall i j k. (i ~> j) -> (j ~> k) -> i ~> k) -> Thrist ~> a b -> a ~> bSource

Equivalent to foldr1 for Thrists.

foldl1Thrist :: (forall i j k. (i ~> j) -> (j ~> k) -> i ~> k) -> Thrist ~> a b -> a ~> bSource

Equivalent to foldl1 for Thrists.

mapMThrist :: Monad m => (forall i j. (i +> j) -> m (i ~> j)) -> Thrist +> a b -> m (Thrist ~> a b)Source

Equivalent to mapM on Thrists.

foldMThrist :: Monad m => (forall j k. (a +> j) -> (j ~> k) -> m (a +> k)) -> (a +> b) -> Thrist ~> b c -> m (a +> c)Source

Equivalent to foldM on Thrists.

# Other list-like functions:

appendThrist :: Thrist ~> a b -> Thrist ~> b c -> Thrist ~> a cSource

Equivalent to (++) for thrists.

nullThrist :: Thrist ~> a b -> BoolSource

Returns True when the Thrist is Nil.