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

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

Alib

Contents

Description

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

Documentation (and further updates in technique) forthcoming.

Synopsis

Constructors (Emitters) and Destructors (Absorbers) -- Functions

nat2 :: (IxI -> Bool) -> (IxI -> IxI) -> A () (II Int) IxISource

Familar Data Structures

set :: (Num a, Eq a) => BinA a [a]Source

list :: BinA a [a]Source

queue :: BinA a [a]Source

pqueue :: Ord a => BinA a [a]Source

pqueueH :: Ord a => BinA a (Heap a)Source

jPqueue :: Ord a => JoinA a []Source

arr :: Ord i => (a -> a -> a) -> BinA (i, a) (FiniteMap i a)Source

fork :: Ord a => A (II a [a]) (IIV [a]) [a]Source

final :: A (II a (Maybe a)) Id (Maybe a)Source

combine :: A (IIV [a] [a]) (II a) [a]Source

tree :: SymA (IIV a) (Tree a)Source

graph :: BinA (Context a b) (Graph a b)Source

type LinGraph a b = II (Context a b) (Graph a b)Source

22 data structures in 22 lines

stack :: BinA a [a]Source

Helpers (Selectors, Appends (with swap))

sel :: (a -> a -> Bool) -> [a] -> [a]Source

rest :: Eq a => [a] -> [a]Source

append213 :: [a] -> [a] -> [a] -> [a]Source

Helpers (Accumulation and Splitting)

accum :: Ord o => (a -> a -> a) -> (o, a) -> FiniteMap o a -> FiniteMap o aSource

add :: (Ord o, Num a) => o -> FiniteMap o a -> FiniteMap o aSource

split_bag :: (Ord o, Eq a, Num a) => FiniteMap o a -> (o, FiniteMap o a)Source

split_arr :: Ord o => FiniteMap o a -> ((o, a), FiniteMap o a)Source

Constructors (Emitters) and Destructors (Absorbers) -- Type Signatures

cNat :: I Int -> IntSource

construct (resp. destroy) a I of Naturals using Ints.

dNat :: Int -> I IntSource

construct (resp. destroy) a I of Naturals using Ints. | construct (resp. destroy) a II of as using Lists

cList :: II a [a] -> [a]Source

dList :: [a] -> II a [a]Source

construct (resp. destroy) a II of as using base Lists

dPqueue :: Ord a => [a] -> II a [a]Source

destroy priority queue (a II over base Lists)

dPqueueH :: Ord a => Heap a -> II a (Heap a)Source

destroy priority queue heap (a II (Bifunctor) over Heaps) | construct (resp. destroy) a II of two Naturals using Ints.

dProd :: Int -> II Int IntSource

construct (resp. destroy) a II of two Naturals using Ints.

type IxISource

Arguments

 = (Int, Int)

a simple type for pairs of integers (not used yet!)

Rose Trees

data Rose a Source

Constructors

Null 
Nd a [Rose a] 

Instances

Show a => Show (Rose a) 

type Forest a = [Rose a]Source

forest :: A (Id [Rose a]) (II [a]) [Rose a]Source

Rose Tree Smart Constructors

cut :: Rose a -> (a, [Rose a])Source

root :: Rose a -> aSource

kids :: Rose t -> [Rose t]Source

Linear Graphs (not really complete)

bufGraph :: JoinA c f -> (c -> Node) -> (c -> Context a b -> [c]) -> A () (II (MContext a b)) (f c, Graph a b)Source

Utilities

q1 :: (t, x, y, z) -> tSource

q2 :: (t, x, y, z) -> xSource

q23 :: (t, x, y, z) -> (x, y)Source

q4 :: (t, x, y, z) -> zSource

o :: (b1 -> c) -> (a -> b -> b1) -> a -> b -> cSource

curried composition

o :: forall a f g b. (b -> a) -> (f -> g -> b) -> f -> g -> a

Extra! (perhaps not needed)

data NoK o Source

Constructors

No 
OK o 

(><) :: (t -> t2) -> (t1 -> t3) -> (t, t1) -> (t2, t3)Source

(/\) :: (t2 -> t) -> (t2 -> t1) -> t2 -> (t, t1)Source