summaryrefslogtreecommitdiff
path: root/transfer/lib/list.tr
diff options
context:
space:
mode:
authorbringert <bringert@cs.chalmers.se>2005-11-30 20:27:01 +0000
committerbringert <bringert@cs.chalmers.se>2005-11-30 20:27:01 +0000
commit7dfa1842859b408d0eadd4d79a5b1ce0267a13b2 (patch)
tree983536942b3836c01033612fb358a619a3505bf0 /transfer/lib/list.tr
parentd92a26fc9be92fb269888947a8b26aa12883065e (diff)
Added bind operators, do-notation, a cons operator and list sytnax.
Diffstat (limited to 'transfer/lib/list.tr')
-rw-r--r--transfer/lib/list.tr31
1 files changed, 0 insertions, 31 deletions
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)
-