0 | module Libraries.Data.List01
5 | data List01 : (nonEmpty : Bool) -> Type -> Type where
7 | (::) : a -> List01 ne a -> List01 True a
10 | fromList : (xs : List a) -> List01 (isCons xs) a
12 | fromList (x :: xs) = x :: fromList xs
15 | (++) : List01 nel a -> List01 ner a -> List01 (nel || ner) a
17 | (x :: xs) ++ ys = x :: xs ++ ys
20 | length : (xs : List01 ne a) -> Nat
22 | length (_ :: xs) = S (length xs)
25 | forget : List01 ne a -> List a
27 | forget (x :: xs) = x :: forget xs
30 | Functor (List01 ne) where
32 | map f (x :: xs) = f x :: map f xs
35 | Show a => Show (List01 ne a) where
36 | show = show . forget
39 | Foldable (List01 ne) where
41 | foldr c n (x :: xs) = c x (foldr c n xs)
44 | foldl f q (x :: xs) = foldl f (f q x) xs
47 | null (_ :: _) = False
51 | foldMap f = foldl (\acc, elem => acc <+> f elem) neutral