1
--------------------------------------------------------------------------------
3
Copyright : (c) Daan Leijen 2002
6
Maintainer : daan@cs.uu.nl
7
Stability : provisional
10
An implementation of John Hughes's efficient catenable sequence type. A lazy sequence
11
@Seq a@ can be concatenated in /O(1)/ time. After
12
construction, the sequence in converted in /O(n)/ time into a list.
14
---------------------------------------------------------------------------------}
15
module UU.DData.Seq( -- * Type
32
{--------------------------------------------------------------------
34
--------------------------------------------------------------------}
37
(<>) :: Seq a -> Seq a -> Seq a
41
{--------------------------------------------------------------------
43
--------------------------------------------------------------------}
44
newtype Seq a = Seq ([a] -> [a])
46
{--------------------------------------------------------------------
48
--------------------------------------------------------------------}
57
cons :: a -> Seq a -> Seq a
61
append :: Seq a -> Seq a -> Seq a
62
append (Seq f) (Seq g)
63
= Seq (\ts -> f (g ts))
66
{--------------------------------------------------------------------
68
--------------------------------------------------------------------}
69
toList :: Seq a -> [a]
73
fromList :: [a] -> Seq a