Control-Monad-MultiPass-0.1.0.0: A Library for Writing Multi-Pass Algorithms.

Safe HaskellSafe

Control.Monad.MultiPass.Example.Repmin

Description

An implementation of the classic repmin algorithm, using the Control.Monad.MultiPass library.

Synopsis

Documentation

data Tree a Source

Binary tree datatype.

Constructors

Leaf !a 
Node !(Tree a) !(Tree a) 

Instances

Eq a => Eq (Tree a) 
Show a => Show (Tree a) 

repmin :: Ord a => Tree a -> Tree aSource

Original algorithm, which uses lazy evaluation.

repminMP :: Ord a => Tree a -> ST2 r w (Tree a)Source

New algorithm, using the Control.Monad.MultiPass library.

repminMP2 :: Ord a => Tree a -> ST2 r w (Tree a)Source

Second version of the new algorithm (repminMP), using the Knot3 instrument, rather than TopKnot.

repminMP3 :: Ord a => Tree a -> ST2 r w (Tree a)Source

Third version of the new algorithm (repminMP), using the Monoid2 instrument.