next up previous
Next: Basic types and functions Up: Hughes's efficient sequence type Previous: Signature

Implementation


>  newtype Sequ a                =  Sequ ([a] -> [a])


>  empty                         =  Sequ (as -> as)

>  single a                      =  Sequ (as -> a : as)

>  Sequ x1 <> Sequ x2            =  Sequ (as -> x1 (x2 as))

>  fromList as                   =  Sequ (as' -> as ++ as')

>  fromListT as                  =  Sequ as

>  toList (Sequ x)               =  x []


>  instance Show a => Show (Sequ a) where

>      showsPrec d a             =  showsPrec d (toList a)

Derived function(s).

>  guard                         :: Bool -> Sequ a -> Sequ a

>  guard False _as               =  empty
>  guard True  as                =  as


next up previous
Next: Basic types and functions Up: Hughes's efficient sequence type Previous: Signature
Ralf Hinze 2001-03-20