9 | data CatList : (Type -> Type) -> Type -> Type where
11 | C : {q : Type -> Type} -> a -> q (Lazy (CatList q a)) -> CatList q a
14 | link : Queue q => CatList q a -> Lazy (CatList q a) -> CatList q a
15 | link c s = case c of
16 | (C x xs) => C x (snoc xs s)
17 | E => idris_crash "link: to E"
20 | linkAll : {q : Type -> Type} -> Queue q => CatList q a -> q (Lazy (CatList q a)) -> CatList q a
24 | else link t (linkAll (force $
Queue.head q') (assert_smaller q' $
tail q'))
28 | {q : Type -> Type} -> Queue q => CatenableList (CatList q) where
35 | xs ++ ys = link xs ys
37 | cons x xs = (C x empty) ++ xs
38 | snoc xs x = xs ++ (C x empty)
40 | head E = idris_crash "empty list"
43 | tail E = idris_crash "empty list"
45 | if isEmpty xs then E else linkAll (force $
Queue.head xs) (tail xs)