From 7dfa1842859b408d0eadd4d79a5b1ce0267a13b2 Mon Sep 17 00:00:00 2001 From: bringert Date: Wed, 30 Nov 2005 20:27:01 +0000 Subject: Added bind operators, do-notation, a cons operator and list sytnax. --- transfer/lib/list.tr | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 transfer/lib/list.tr (limited to 'transfer/lib/list.tr') diff --git a/transfer/lib/list.tr b/transfer/lib/list.tr deleted file mode 100644 index da3bcc516..000000000 --- a/transfer/lib/list.tr +++ /dev/null @@ -1,31 +0,0 @@ -import prelude -import nat - -data List : (_:Type) -> Type where - Nil : (A:Type) -> List A - Cons : (A:Type) -> A -> List A -> List A - -size : (A:Type) -> List A -> Nat -size _ (Nil _) = Zero -size A (Cons _ x xs) = Succ (size A xs) - -map : (A:Type) -> (B:Type) -> (A -> B) -> List A -> List B -map _ B _ (Nil _) = Nil B -map A B f (Cons _ x xs) = Cons B (f x) (map A B f xs) - -append : (A:Type) -> (xs:List A) -> List A -> List A -append A xs ys = foldr A (List A) (Cons A) ys xs - -concat : (A : Type) -> List (List A) -> List A -concat A = foldr (List A) (List A) (append A) (Nil A) - -foldr : (A : Type) -> (B : Type) -> (A -> B -> B) -> B -> List A -> B -foldr _ _ _ x (Nil _) = x -foldr A B f x (Cons _ y ys) = f y (foldr A B f x ys) - --- Instances: - -monad_List : Monad List -monad_list = rec return = \A -> \x -> Cons A x (Nil A) - bind = \A -> \B -> \m -> \k -> concat B (map A B k m) - -- cgit v1.2.3