metamorphic-0.1.2.3: metamorphisms: ana . cata or understanding folds and unfolds

Portabilityportable
Stabilityexperimental
MaintainerDrew Day <drewday@gmail.com>
Safe HaskellSafe-Infered

A

Contents

Description

Code adapted from: http://web.engr.oregonstate.edu/~erwig/meta/

Documentation (and further updates in technique) forthcoming.

Synopsis

Documentation

class IIFunctor f whereSource

A standard Bifunctor, but with a Roman Numeral naming scheme:

II
instead of Bi
fmapII
instead of bimap
fmapLI
instead of first
fmapIR
instead of second

This is to remind us that the other column remains intact when focus on one (L or R).

Methods

fmapII :: (a -> b) -> (c -> d) -> f a c -> f b dSource

fmapLI :: (a -> b) -> f a c -> f b cSource

fmapIR :: (b -> c) -> f a b -> f a cSource

data Id a Source

Constructors

Id a 

Instances

fromId :: (a -> b) -> Id a -> bSource

toId :: (b -> a) -> b -> Id aSource

fromU :: t -> (a -> t) -> I a -> tSource

fromB :: t -> (a -> b -> t) -> II a b -> tSource

fromT :: t -> (a -> b -> b -> t) -> IIV a b -> tSource

fromP :: t -> (a -> [b] -> t) -> Power a b -> tSource

toU :: (t -> Bool) -> (t -> a) -> t -> I aSource

toB :: (t -> Bool) -> (t -> a) -> (t -> b) -> t -> II a bSource

toT :: (t -> Bool) -> (t -> a) -> (t -> b) -> (t -> b) -> t -> IIV a bSource

toP :: (t -> Bool) -> (t -> a) -> (t -> [b]) -> t -> Power a bSource

toP' :: (t -> Bool) -> (t -> (a, [b])) -> t -> Power a bSource

toB' :: (t -> Bool) -> (t -> (a, b)) -> t -> II a bSource

data I a Source

Constructors

U_I_U 
I a 

Instances

data II a b Source

Constructors

UII_U 
II a b 

Instances

data IIV a b Source

Constructors

UIIVU 
IIV a b b 

Instances

data Power a b Source

Constructors

UnitP 
Many a [b] 

Instances

ntBU :: (a -> b -> c) -> II a b -> I cSource

ntTB :: (a -> c) -> (b -> b -> d) -> IIV a b -> II c dSource

ntPB :: (a -> c) -> ([b] -> d) -> Power a b -> II c dSource

data A s g t Source

Constructors

A (s -> t) (t -> g t) 

con :: A t t1 t2 -> t -> t2Source

des :: A t t1 t2 -> t2 -> t1 t2Source

type BinA a t = SymA (II a) tSource

type PowA a t = SymA (Power a) tSource

type SymA g t = A (g t) g tSource

type JoinA a g = A (II [a] (g a)) (II a) (g a)Source

joinView :: Functor g => A (II a t) g t -> A (II [a] t) g tSource

Equip an A having linear constructor with a join view

maybeView :: Functor g => A (II a t) g t -> A (II (Maybe a) t) g tSource

Fold and Unfold

fold :: Functor g => (g u -> u) -> A s g t -> t -> uSource

unfold :: (Functor f, Functor g) => (t -> f t) -> A (f u) g u -> t -> uSource

trans :: (Functor g, Functor h) => (g u -> r) -> A s g t -> A r h u -> t -> uSource

transit :: (Functor g, Functor h) => A s g t -> A (g u) h u -> t -> uSource

via :: (Functor g, Functor h, Functor i) => A s g t -> A (g u) h u -> A (h v) i v -> t -> vSource

hylo :: Functor f => (f b -> b) -> (a -> f a) -> a -> bSource

Hylomorphisms in binary and triplet form (just for completeness)

hylot :: Functor f => (f b -> g b) -> (g b -> b) -> (a -> f a) -> a -> bSource

hhh :: Functor f => (f b -> i b) -> (i b -> g b) -> (g b -> b) -> (a -> f a) -> a -> bSource

h :: Functor f => (f b -> i b) -> (i b -> j b) -> (j b -> k b) -> (k b -> b) -> (a -> f a) -> a -> bSource

A simple Stream ADT

stream :: Functor g => [SymA g t] -> t -> tSource