git.iko.soy/distributed-process
on send-direct help sign in
27 lines 698 B history raw
1-- | Spine and element strict list
2module Control.Distributed.Process.Internal.StrictList
3 ( StrictList(..)
4 , append
5 , foldr
6 ) where
8import Prelude hiding (length, reverse, foldr)
10-- | Strict list
11data StrictList a
12 = Cons !a !(StrictList a)
13 | Nil
14 | Snoc !(StrictList a) !a
15 | Append !(StrictList a) !(StrictList a)
17append :: StrictList a -> StrictList a -> StrictList a
18append Nil l = l
19append l Nil = l
20append l1 l2 = l1 `Append` l2
22foldr :: (a -> b -> b) -> b -> StrictList a -> b
23foldr f c0 xs0 = go xs0 c0
24 where go Nil c = c
25 go (Cons x xs) c = f x (go xs c)
26 go (Snoc xs x) c = go xs (f x c)
27 go (Append xs ys) c = go xs (go ys c)