--- /dev/null
+definition module Map\r
+\r
+//import BinTree\r
+import StdMaybe\r
+\r
+class Map c :: (a -> b) (c a) -> c b\r
+\r
+instance Map []\r
+instance Map Maybe\r
+//instance Map Tree\r
--- /dev/null
+implementation module Map\r
+\r
+//import BinTree\r
+import StdMaybe\r
+import StdList\r
+\r
+class Map c :: (a -> b) (c a) -> c b\r
+\r
+instance Map [] where \r
+ Map f [] = []\r
+ Map f [x:xs] = [f x: Map f xs]\r
+\r
+instance Map Maybe where\r
+ Map f Nothing = Nothing\r
+ Map f (Just x) = Just (f x)\r
+\r
+//instance Map Tree where\r
+// Map f Leaf = Leaf\r
+// Map f (Node x l r) = Node (f x) (mapTree f l) (mapTree f r)\r
--- /dev/null
+module Mappen\r
+\r
+import StdEnv\r
+import Map\r
+\r
+Start = (\r
+ Map ((+) 1) (Just 42), \r
+ Map ((+) 1) [1..10])\r
+//Map ((+) 1) t7)\r
--- /dev/null
+definition module Random
+
+ // Random number generator voor Linux gebruikers
+ // interface compatible met Random.dcl (helaas)
+ // -- mschool@science.ru.nl
+
+import StdFile
+
+:: RandomSeed
+
+// nullRandomSeed generates a fixed RandomSeed
+nullRandomSeed :: RandomSeed
+
+// GetNewRandomSeed generates a good RandomSeed, using /dev/urandom
+getNewRandomSeed :: !*env -> (!RandomSeed, !*env) | FileSystem env
+
+// Given a RandomSeed, Random generates a random number and a new RandomSeed.
+random :: !RandomSeed -> .(!Int, !RandomSeed)
+
--- /dev/null
+implementation module Random
+
+import StdFile, StdList, StdMisc, StdArray, Random
+
+:: RandomSeed :== Int
+
+nullRandomSeed :: RandomSeed
+nullRandomSeed = 0
+
+getNewRandomSeed :: !*env -> (!RandomSeed, !*env) | FileSystem env
+getNewRandomSeed env
+# (ok, src, env) = sfopen "/dev/urandom" FReadData env
+| not ok => abort "could not open /dev/urandom"
+# (bytes, src) = sfreads src 4
+ seed = foldl (\x y->(x<<8)+toInt y) 0 [c \\ c<-:bytes]
+| otherwise => (seed, env)
+
+random :: !RandomSeed -> .(!Int, !RandomSeed)
+random seed = (seed>>16 bitand 0xFFFF, seed*0x08088405+1)
+
--- /dev/null
+module ReturnEnBind\r
+\r
+import StdEnv, Random\r
+\r
+Start = (r1, r2, r3, r4, nullRandomSeed, s1, s2, s3)\r
+ where\r
+ (r1, s1) = som2 nullRandomSeed\r
+ (r2, s2) = som2 s1\r
+ (r3, s3) = som2 s2\r
+ (r4, _) = som2 s3\r
+\r
+(bind1) infix 0 :: (St s a) (a -> (St s b)) -> St s b\r
+(bind1) f g = uncurry g o f\r
+\r
+som2 :: (RandomSeed -> (Int,RandomSeed))\r
+som2 = (\s -> random s) bind1 (\a -> random (snd a))\r
+\r
+seqList1 :: [St s a] -> St s [a]\r
+seqList1 ...\r
--- /dev/null
+module StdIOMonad
+
+import StdEnv, StdMaybe, StdMonad, StdFile
+
+:: IO a = IO (*World -> *(a, *World))
+
+read :: *World -> (IO String, *World)
+read world
+# (io, world) = stdio world
+# (line, io) = freadline io
+# (ok, world) = fclose io
+| not ok = abort "Couldn't close console"
+| otherwise = line
+
+instance return IO where
+ return x = IO (\w = (x, w))
+
+instance >>= IO where
+ >>= (IO f) g = (IO f)
+
+Start :: *World -> (IO String, *World)
+Start world = read
--- /dev/null
+definition module StdMonad\r
+\r
+class return c :: a -> c a\r
+class (>>=) infix 0 c :: (c a) (a -> c b) -> c b\r
+class fail c :: c a\r
+\r
+class Monad c | return, >>= c\r
+class MonadFail c | Monad, fail c\r
--- /dev/null
+implementation module StdMonad\r