summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fp2/week2/ReturnEnBind.icl19
-rw-r--r--fp2/week2/mart/EchoMonad.icl14
-rw-r--r--fp2/week2/mart/StdIOMonad.dcl26
-rw-r--r--fp2/week2/mart/StdIOMonad.icl88
-rw-r--r--fp2/week2/mart/StdListMonad.dcl7
-rw-r--r--fp2/week2/mart/StdListMonad.icl7
-rw-r--r--fp2/week2/mart/StdMaybe.dcl41
-rw-r--r--fp2/week2/mart/StdMaybe.icl65
-rw-r--r--fp2/week2/mart/StdMaybeMonad.dcl9
-rw-r--r--fp2/week2/mart/StdMaybeMonad.icl10
-rw-r--r--fp2/week2/mart/Test.dcl1
-rw-r--r--fp2/week2/mart/Test.icl13
-rw-r--r--fp2/week2/mart/ToonFileMonad.icl30
-rw-r--r--fp2/week2/mart/camil.txt2
-rw-r--r--fp2/week2/mart/camil2.txt0
-rw-r--r--fp2/week2/mart/oldold/old/Map.dcl10
-rw-r--r--fp2/week2/mart/oldold/old/Map.icl19
-rw-r--r--fp2/week2/mart/oldold/old/Mappen.icl9
-rw-r--r--fp2/week2/mart/oldold/old/Random.dcl19
-rw-r--r--fp2/week2/mart/oldold/old/Random.icl20
-rw-r--r--fp2/week2/mart/oldold/old/ReturnEnBind.icl19
-rw-r--r--fp2/week2/mart/oldold/old/StdIOMonad.dcl40
-rw-r--r--fp2/week2/mart/oldold/old/StdIOMonad.icl93
-rw-r--r--fp2/week2/mart/oldold/old/StdMaybeMonad.dcl9
-rw-r--r--fp2/week2/mart/oldold/old/StdMaybeMonad.icl10
-rw-r--r--fp2/week2/mart/oldold/old/StdMonad.dcl8
-rw-r--r--fp2/week2/mart/oldold/old/StdMonad.icl1
-rw-r--r--fp2/week2/mart/s4109503_s4498062_fp2_w2.tar.gzbin0 -> 2207 bytes
28 files changed, 80 insertions, 509 deletions
diff --git a/fp2/week2/ReturnEnBind.icl b/fp2/week2/ReturnEnBind.icl
deleted file mode 100644
index 0bece5f..0000000
--- a/fp2/week2/ReturnEnBind.icl
+++ /dev/null
@@ -1,19 +0,0 @@
-module ReturnEnBind
-
-import StdEnv, Random
-
-Start = 42
-
-(bind1) infix 0 :: (St s a) (a -> (St s b)) -> St s b
-//(bind1) infix 0 :: (s -> *(a,s)) (a -> (a -> *(a,s))) -> (s -> *(b,s))
-(bind1) f1 f2 = \st0 f2 (fst (f1 st0) (snd (f1 st0))
-// (r, st1) = f1 st0
-//(bind) f f2 :== \st0 -> let (r,st1) = f st0
-// in f2 r st1
-
-
-som2 :: (RandomSeed -> (Int,RandomSeed))
-som2 ...
-
-seqList1 :: [St s a] -> St s [a]
-seqList1 ...
diff --git a/fp2/week2/mart/EchoMonad.icl b/fp2/week2/mart/EchoMonad.icl
deleted file mode 100644
index 3bcab11..0000000
--- a/fp2/week2/mart/EchoMonad.icl
+++ /dev/null
@@ -1,14 +0,0 @@
-module EchoMonad
-
-import StdString // expliciete import uit StdEnv om nameclash met StdFunc / StdIOMonad te voorkomen
-import StdIOMonad
-import StdMaybeMonad
-
-Start :: *World -> (Void,*World)
-Start world = doIO echo world
-
-echo :: IO Void
-echo = read >>= \regel ->
- if (regel == "\n")
- (return Void)
- (write regel >>= \_ -> echo)
diff --git a/fp2/week2/mart/StdIOMonad.dcl b/fp2/week2/mart/StdIOMonad.dcl
index 0801928..580efaa 100644
--- a/fp2/week2/mart/StdIOMonad.dcl
+++ b/fp2/week2/mart/StdIOMonad.dcl
@@ -2,14 +2,14 @@ definition module StdIOMonad
// Deze module verpakt een aantal StdFile functies in een monadische jas
-import StdMonad, StdMaybeMonad
+import StdMonad, StdMaybe
:: IO a
:: *W
:: Void = Void
:: Filemode = Lees | Schrijf
:: Filenaam :== String
-:: Filehandle
+:: Filehandle :== String
// voer monadische I/O actie uit op de wereld:
doIO:: (IO a) *World -> *(a, *W)
@@ -25,16 +25,16 @@ read :: IO String
write :: String -> IO Void
// open de file met gegeven filenaam en mode:
-//open :: Filenaam Filemode -> IO (Maybe Filehandle)
+open :: Filenaam Filemode -> IO (Maybe Filehandle)
// sluit de file met gegeven filenaam:
-//close :: Filehandle -> IO Bool
-//
-//// bepaal of het lezen van de file klaar is:
-//eof :: Filehandle -> IO Bool
-//
-//// lees een regel van een file:
-//readline :: Filehandle -> IO (Maybe String)
-//
-//// schrijf een regel naar een file:
-//writeline :: String Filehandle -> IO Bool
+close :: Filehandle -> IO Bool
+
+// bepaal of het lezen van de file klaar is:
+eof :: Filehandle -> IO Bool
+
+// lees een regel van een file:
+readline :: Filehandle -> IO (Maybe String)
+
+// schrijf een regel naar een file:
+writeline :: String Filehandle -> IO Bool
diff --git a/fp2/week2/mart/StdIOMonad.icl b/fp2/week2/mart/StdIOMonad.icl
index b0f2b4f..ffa2857 100644
--- a/fp2/week2/mart/StdIOMonad.icl
+++ b/fp2/week2/mart/StdIOMonad.icl
@@ -1,7 +1,5 @@
implementation module StdIOMonad
-// Deze module verpakt StdFile in een monadische jas
-
import StdBool
import StdEnum
import StdFile
@@ -19,27 +17,25 @@ import StdTuple
:: Filenaam :== String
:: Filehandle :== String
+// Conversion from our filemodes to StdFile filemodes
instance toInt Filemode where
toInt Lees = FReadText
toInt Schrijf = FWriteText
-//voer monadische I/O actie uit op de wereld:
+// Apply the monadic program on the world
doIO:: (IO a) *World -> *(a, *W)
doIO (IO f) w = f (w, [])
+// Lift the value out of the monadic domain
unIO:: (IO a) -> *W -> *(a, *W)
unIO (IO f) = f
-// IO is een monad:
instance return IO where
return x = IO (\w -> (x, w))
instance >>= IO where
(>>=) (IO f) g = IO (\w = let (a, w1) = f w in unIO (g a) w1)
-//Start world = doIO (read >>= (\w = return w)) (world, "")
-//Start world = doIO (open "camilt.txt" Lees) (world, "")
-//Start world = doIO (read >>= (\w = read)) (world, "")
-
+// Read one line from the console
read:: IO String
read = IO read`
where
@@ -50,7 +46,7 @@ read = IO read`
# (_, world) = fclose io world
= (line, (world, s))
-// schrijf regel naar de console:
+// Write a line from the console
write :: String -> IO Void
write s = IO (write` s)
where
@@ -61,26 +57,7 @@ write s = IO (write` s)
# (_, world) = fclose io world
= (Void, (world, s))
-
-Start world = doIO (
- open "camil.txt" Lees >>=
- \y = eof "camil.txt") world
-
-// open de file met gegeven filenaam en mode:
-find:: Filehandle *[*(Filehandle, *File)] -> (Maybe *(Filehandle, *File), *[*(Filehandle, *File)])
-find fh fs
-# (fhs, fis) = unzip fs
-# fhsC = zip2 [0..length fhs] fhs
-# index = [(i, h) \\ (i, h) <- fhsC | h == fh]
-| length index == 0 = (Nothing, zip2 fhs fis)
-# index = fst (hd index)
-# (fis1, fis2) = splitAt index fis
-# (fhs1, fhs2) = splitAt index fhs
-# (thefile, fis2) = splitAt 1 fis2
-# (thehandle, fhs2) = splitAt 1 fhs2
-= (Just (hd thehandle, hd thefile), zip2 (fhs1 ++ fhs2) (fis1 ++ fis2))
-
-
+// Open a file
open:: Filenaam Filemode -> IO (Maybe Filehandle)
open s m = IO (open` s m)
where
@@ -90,13 +67,14 @@ open s m = IO (open` s m)
# (ok, file, world) = fopen fp (toInt m) world
= (Just fp, (world, [(fp, file):fs]))
-// sluit de file met gegeven filenaam:
+// Close a file. If the file can't be closed by the system the program will
+// abort
close:: Filehandle -> IO Bool
close fh = IO (close` fh)
where
close`:: Filehandle *W -> *(Bool, *W)
close` fp (world, fs)
- # (currentfiletuple, fs) = find fp fs
+ # (currentfiletuple, fs) = getFH fp fs
| isNothing currentfiletuple = (False, (world, fs))
# (currentfh, currentfile) = fromJust currentfiletuple
# (ok, world) = fclose currentfile world
@@ -104,21 +82,57 @@ close fh = IO (close` fh)
| otherwise = (True, (world, fs))
-// bepaal of het lezen van de file klaar is:
+// Determine if the file is at the end. This will abort when the file is not
+// open or error if the file is not opened for reading.
eof :: Filehandle -> IO Bool
eof fh = IO (eof` fh)
where
eof`:: Filehandle *W -> *(Bool, *W)
eof` fp (world, fs)
- # (currentfiletuple, fs) = find fp fs
+ # (currentfiletuple, fs) = getFH fp fs
| isNothing currentfiletuple = abort "Can't do eof on non-existing file"
# (currentfh, currentfile) = fromJust currentfiletuple
# (ok, file) = fend currentfile
= (ok, (world, [(currentfh, file):fs]))
-// lees een regel van een file:
-//readline :: Filehandle -> IO (Maybe String)
-
+// Read one line from a file (including newline). This will abort when the file
+// is not open or error if the file is not opened for reading.
+readline :: Filehandle -> IO (Maybe String)
+readline fh = IO (readline` fh)
+ where
+ readline` :: Filehandle *W -> *(Maybe String, *W)
+ readline` fh (world, fs)
+ # (currentfiletuple, fs) = getFH fh fs
+ | isNothing currentfiletuple = abort "File not open"
+ # (currentfh, currentfile) = fromJust currentfiletuple
+ # (s, currentfile) = freadline currentfile
+ = (Just s, (world, [(currentfh, currentfile):fs]))
-// schrijf een regel naar een file:
+// Write one line from a file (will not append newline). This will abort when
+// the file is not open or error if the file is not opened for writing.
writeline :: String Filehandle -> IO Bool
+writeline s fh = IO (writeline` s fh)
+ where
+ writeline` :: String Filehandle *W -> *(Bool, *W)
+ writeline` s fh (world, fs)
+ # (currentfiletuple, fs) = getFH fh fs
+ | isNothing currentfiletuple = abort "File not open"
+ # (currentfh, currentfile) = fromJust currentfiletuple
+ # currentfile = fwrites s currentfile
+ = (True, (world, [(currentfh, currentfile):fs]))
+
+// Gets the file associated with the filehandle given, this is done in a very
+// ugly way to retain uniqueness...
+getFH:: Filehandle *[*(Filehandle, *File)] ->
+ (Maybe *(Filehandle, *File), *[*(Filehandle, *File)])
+getFH fh fs
+# (fhs, fis) = unzip fs
+# fhsC = zip2 [0..length fhs] fhs
+# index = [(i, h) \\ (i, h) <- fhsC | h == fh]
+| length index == 0 = (Nothing, zip2 fhs fis)
+# index = fst (hd index)
+# (fis1, fis2) = splitAt index fis
+# (fhs1, fhs2) = splitAt index fhs
+# (thefile, fis2) = splitAt 1 fis2
+# (thehandle, fhs2) = splitAt 1 fhs2
+= (Just (hd thehandle, hd thefile), zip2 (fhs1 ++ fhs2) (fis1 ++ fis2))
diff --git a/fp2/week2/mart/StdListMonad.dcl b/fp2/week2/mart/StdListMonad.dcl
deleted file mode 100644
index 576ef55..0000000
--- a/fp2/week2/mart/StdListMonad.dcl
+++ /dev/null
@@ -1,7 +0,0 @@
-definition module StdListMonad
-
-import StdMonad
-
-instance return []
-instance >>= []
-instance fail []
diff --git a/fp2/week2/mart/StdListMonad.icl b/fp2/week2/mart/StdListMonad.icl
deleted file mode 100644
index b3b3d62..0000000
--- a/fp2/week2/mart/StdListMonad.icl
+++ /dev/null
@@ -1,7 +0,0 @@
-implementation module StdListMonad
-
-import StdMonad
-
-instance return [] where return x = [x]
-instance >>= [] where >>= xs f = [y \\ x <- xs, y <- f x]
-instance fail [] where fail = []
diff --git a/fp2/week2/mart/StdMaybe.dcl b/fp2/week2/mart/StdMaybe.dcl
deleted file mode 100644
index 2403683..0000000
--- a/fp2/week2/mart/StdMaybe.dcl
+++ /dev/null
@@ -1,41 +0,0 @@
-definition module StdMaybe
-
-// ********************************************************************************
-// Clean StdLib library module, version 1.0
-// ********************************************************************************
-
-from StdFunc import :: St;
-from StdOverloaded import class ==(..);
-
-:: Maybe x
- = Just x
- | Nothing
-
-isJust :: !(Maybe .x) -> Bool // case @1 of (Just _) -> True; _ -> False
-isNothing :: !(Maybe .x) -> Bool // not o isJust
-fromJust :: !(Maybe .x) -> .x // \(Just x) -> x
-
-// for possibly unique elements:
-u_isJust :: !u:(Maybe .x) -> (!Bool, !u:Maybe .x)
-u_isNothing :: !u:(Maybe .x) -> (!Bool, !u:Maybe .x)
-
-accMaybe :: .(St .x .a) !u:(Maybe .x) -> (!Maybe .a,!u:Maybe .x)
-// accMaybe f (Just x) = (Just (fst (f x)),Just (snd (f x)))
-// accMaybe f Nothing = (Nothing,Nothing)
-
-mapMaybe :: .(.x -> .y) !(Maybe .x) -> Maybe .y
-// mapMaybe f (Just x) = Just (f x)
-// mapMaybe f Nothing = Nothing
-
-instance == (Maybe x) | == x
-// Nothing==Nothing
-// Just a ==Just b <= a==b
-
-maybeToList :: !(Maybe .a) -> [.a];
-// returns list with no or one element
-
-listToMaybe :: ![.a] -> .Maybe .a;
-// returns Just head of list if possible
-
-catMaybes :: ![Maybe .a] -> .[.a];
-// catMaybes ms = [ m \\ Just m <- ms ]
diff --git a/fp2/week2/mart/StdMaybe.icl b/fp2/week2/mart/StdMaybe.icl
deleted file mode 100644
index 4eed325..0000000
--- a/fp2/week2/mart/StdMaybe.icl
+++ /dev/null
@@ -1,65 +0,0 @@
-implementation module StdMaybe
-
-// ********************************************************************************
-// Clean StdLib library module, version 1.0
-// ********************************************************************************
-
-from StdFunc import :: St;
-from StdOverloaded import class ==(..);
-
-:: Maybe x
- = Just x
- | Nothing
-
-isJust :: !(Maybe .x) -> Bool
-isJust Nothing = False
-isJust _ = True
-
-isNothing :: !(Maybe .x) -> Bool
-isNothing Nothing = True
-isNothing _ = False
-
-u_isJust :: !u:(Maybe .x) -> (!Bool, !u:Maybe .x)
-u_isJust nothing=:Nothing
- = (False, nothing)
-u_isJust just
- = (True, just)
-
-u_isNothing :: !u:(Maybe .x) -> (!Bool, !u:Maybe .x)
-u_isNothing nothing=:Nothing
- = (True, nothing)
-u_isNothing just
- = (False,just)
-
-fromJust :: !(Maybe .x) -> .x
-fromJust (Just x) = x
-
-accMaybe :: .(St .x .a) !u:(Maybe .x) -> (!Maybe .a,!u:Maybe .x)
-accMaybe f (Just x)
- # (a,x) = f x
- = (Just a,Just x)
-accMaybe _ nothing
- = (Nothing,nothing)
-
-mapMaybe :: .(.x -> .y) !(Maybe .x) -> Maybe .y
-mapMaybe f (Just x) = Just (f x)
-mapMaybe _ nothing = Nothing
-
-instance == (Maybe x) | == x where
- (==) Nothing maybe = case maybe of
- Nothing -> True
- just -> False
- (==) (Just a) maybe = case maybe of
- Just b -> a==b
- nothing -> False
-
-maybeToList :: !(Maybe .a) -> [.a];
-maybeToList Nothing = []
-maybeToList (Just a) = [a]
-
-listToMaybe :: ![.a] -> .Maybe .a;
-listToMaybe [] = Nothing
-listToMaybe [a:_] = Just a
-
-catMaybes :: ![Maybe .a] -> .[.a];
-catMaybes ms = [ m \\ Just m <- ms ]
diff --git a/fp2/week2/mart/StdMaybeMonad.dcl b/fp2/week2/mart/StdMaybeMonad.dcl
deleted file mode 100644
index e9ebec1..0000000
--- a/fp2/week2/mart/StdMaybeMonad.dcl
+++ /dev/null
@@ -1,9 +0,0 @@
-definition module StdMaybeMonad
-
-import StdMonad
-
-:: Maybe a = Nothing | Just a
-
-instance return Maybe
-instance >>= Maybe
-instance fail Maybe
diff --git a/fp2/week2/mart/StdMaybeMonad.icl b/fp2/week2/mart/StdMaybeMonad.icl
deleted file mode 100644
index 1c6277d..0000000
--- a/fp2/week2/mart/StdMaybeMonad.icl
+++ /dev/null
@@ -1,10 +0,0 @@
-implementation module StdMaybeMonad
-
-import StdMonad
-
-:: Maybe a = Nothing | Just a
-
-instance return Maybe where return x = Just x
-instance >>= Maybe where >>= (Just x) f = f x
- >>= Nothing f = Nothing
-instance fail Maybe where fail = Nothing
diff --git a/fp2/week2/mart/Test.dcl b/fp2/week2/mart/Test.dcl
new file mode 100644
index 0000000..21f08d1
--- /dev/null
+++ b/fp2/week2/mart/Test.dcl
@@ -0,0 +1 @@
+definition module Test
diff --git a/fp2/week2/mart/Test.icl b/fp2/week2/mart/Test.icl
new file mode 100644
index 0000000..ff32dfe
--- /dev/null
+++ b/fp2/week2/mart/Test.icl
@@ -0,0 +1,13 @@
+implementation module Test
+
+import StdIOMonad
+
+// This assumes a file "camil.txt" and writes a line from it to "mart.txt"
+Start world = doIO (
+ open "camil.txt" Lees >>=
+ \_ = open "mart.txt" Schrijf >>=
+ \_ = readline "camil.txt" >>=
+ \l = writeline (fromJust l) "mart.txt" >>=
+ \_ = close "camil.txt" >>=
+ \_ = close "mart.txt"
+ ) world
diff --git a/fp2/week2/mart/ToonFileMonad.icl b/fp2/week2/mart/ToonFileMonad.icl
deleted file mode 100644
index acd62c2..0000000
--- a/fp2/week2/mart/ToonFileMonad.icl
+++ /dev/null
@@ -1,30 +0,0 @@
-module ToonFileMonad
-
-import StdArray, StdInt, StdString // expliciete imports van StdEnv om name-clash met StdFunc en StdIOMonad te voorkomen
-import StdIOMonad
-import StdMaybeMonad
-
-Start :: *World -> (Void,*World)
-Start world = doIO toon world
-
-toon :: IO Void
-toon = write "Voer een filenaam in: " >>= \_ ->
- read >>= \filenaam ->
- open (filenaam%(0,size filenaam-2)) Lees >>= \misschien_filehandle ->
- case misschien_filehandle of
- Nothing
- = write ("Kon " +++ filenaam +++ " niet openen.\n") >>= \_ ->
- return Void
- Just filehandle
- = toon_inhoud filehandle
-
-toon_inhoud :: Filehandle -> IO Void
-toon_inhoud filehandle
- = eof filehandle >>= \einde ->
- if einde
- (return Void)
- (readline filehandle >>= \misschien_regel ->
- case misschien_regel of
- Nothing = return Void
- Just regel = write regel >>= \_ -> toon_inhoud filehandle
- )
diff --git a/fp2/week2/mart/camil.txt b/fp2/week2/mart/camil.txt
index e69de29..b8b933b 100644
--- a/fp2/week2/mart/camil.txt
+++ b/fp2/week2/mart/camil.txt
@@ -0,0 +1,2 @@
+Line one
+Line two
diff --git a/fp2/week2/mart/camil2.txt b/fp2/week2/mart/camil2.txt
deleted file mode 100644
index e69de29..0000000
--- a/fp2/week2/mart/camil2.txt
+++ /dev/null
diff --git a/fp2/week2/mart/oldold/old/Map.dcl b/fp2/week2/mart/oldold/old/Map.dcl
deleted file mode 100644
index 4848e1a..0000000
--- a/fp2/week2/mart/oldold/old/Map.dcl
+++ /dev/null
@@ -1,10 +0,0 @@
-definition module Map
-
-//import BinTree
-import StdMaybe
-
-class Map c :: (a -> b) (c a) -> c b
-
-instance Map []
-instance Map Maybe
-//instance Map Tree
diff --git a/fp2/week2/mart/oldold/old/Map.icl b/fp2/week2/mart/oldold/old/Map.icl
deleted file mode 100644
index d248c66..0000000
--- a/fp2/week2/mart/oldold/old/Map.icl
+++ /dev/null
@@ -1,19 +0,0 @@
-implementation module Map
-
-//import BinTree
-import StdMaybe
-import StdList
-
-class Map c :: (a -> b) (c a) -> c b
-
-instance Map [] where
- Map f [] = []
- Map f [x:xs] = [f x: Map f xs]
-
-instance Map Maybe where
- Map f Nothing = Nothing
- Map f (Just x) = Just (f x)
-
-//instance Map Tree where
-// Map f Leaf = Leaf
-// Map f (Node x l r) = Node (f x) (mapTree f l) (mapTree f r)
diff --git a/fp2/week2/mart/oldold/old/Mappen.icl b/fp2/week2/mart/oldold/old/Mappen.icl
deleted file mode 100644
index faca555..0000000
--- a/fp2/week2/mart/oldold/old/Mappen.icl
+++ /dev/null
@@ -1,9 +0,0 @@
-module Mappen
-
-import StdEnv
-import Map
-
-Start = (
- Map ((+) 1) (Just 42),
- Map ((+) 1) [1..10])
-//Map ((+) 1) t7)
diff --git a/fp2/week2/mart/oldold/old/Random.dcl b/fp2/week2/mart/oldold/old/Random.dcl
deleted file mode 100644
index 47a7c18..0000000
--- a/fp2/week2/mart/oldold/old/Random.dcl
+++ /dev/null
@@ -1,19 +0,0 @@
-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)
-
diff --git a/fp2/week2/mart/oldold/old/Random.icl b/fp2/week2/mart/oldold/old/Random.icl
deleted file mode 100644
index b6e0768..0000000
--- a/fp2/week2/mart/oldold/old/Random.icl
+++ /dev/null
@@ -1,20 +0,0 @@
-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)
-
diff --git a/fp2/week2/mart/oldold/old/ReturnEnBind.icl b/fp2/week2/mart/oldold/old/ReturnEnBind.icl
deleted file mode 100644
index 6c3f8e4..0000000
--- a/fp2/week2/mart/oldold/old/ReturnEnBind.icl
+++ /dev/null
@@ -1,19 +0,0 @@
-module ReturnEnBind
-
-import StdEnv, Random
-
-Start = (r1, r2, r3, r4, nullRandomSeed, s1, s2, s3)
- where
- (r1, s1) = som2 nullRandomSeed
- (r2, s2) = som2 s1
- (r3, s3) = som2 s2
- (r4, _) = som2 s3
-
-(bind1) infix 0 :: (St s a) (a -> (St s b)) -> St s b
-(bind1) f g = uncurry g o f
-
-som2 :: (RandomSeed -> (Int,RandomSeed))
-som2 = (\s -> random s) bind1 (\a -> random (snd a))
-
-seqList1 :: [St s a] -> St s [a]
-seqList1 ...
diff --git a/fp2/week2/mart/oldold/old/StdIOMonad.dcl b/fp2/week2/mart/oldold/old/StdIOMonad.dcl
deleted file mode 100644
index 375f077..0000000
--- a/fp2/week2/mart/oldold/old/StdIOMonad.dcl
+++ /dev/null
@@ -1,40 +0,0 @@
-definition module StdIOMonad
-
-// Deze module verpakt een aantal StdFile functies in een monadische jas
-
-import StdMonad, StdMaybeMonad
-
-:: IO a
-:: Void = Void
-:: Filemode = Lees | Schrijf
-:: Filenaam :== String
-:: *Filehandle
-
-// voer monadische I/O actie uit op de wereld:
-//doIO :: (IO a) *World -> *(a,*World)
-
-// IO is een monad:
-//instance return IO
-//instance >>= IO
-
-// lees regel van de console:
-read :: IO String
-
-/*
-// schrijf regel naar de console:
-write :: String -> IO Void
-
-// open de file met gegeven filenaam en mode:
-open :: Filenaam Filemode -> IO (Maybe Filehandle)
-
-// sluit de file met gegeven filenaam:
-close :: Filehandle -> IO Bool
-
-// bepaal of het lezen van de file klaar is:
-eof :: Filehandle -> IO Bool
-
-// lees een regel van een file:
-readline :: Filehandle -> IO (Maybe String)
-
-// schrijf een regel naar een file:
-writeline :: String Filehandle -> IO Bool*/
diff --git a/fp2/week2/mart/oldold/old/StdIOMonad.icl b/fp2/week2/mart/oldold/old/StdIOMonad.icl
deleted file mode 100644
index 0338a44..0000000
--- a/fp2/week2/mart/oldold/old/StdIOMonad.icl
+++ /dev/null
@@ -1,93 +0,0 @@
-implementation module StdIOMonad
-
-//Deze module verpakt StdFile in een monadische jas
-
-import StdFile
-import StdMonad
-import StdMaybeMonad
-
-
-:: IO a = IO (*World Filehandle -> *(a, *World, Filehandle))
-:: Void = Void
-:: Filemode = Lees | Schrijf
-:: Filenaam :== String
-:: *Filehandle = None | FH *(Bool, Filemode, *File)
-
-toInt :: Filemode -> Int
-toInt Lees = FReadText
-toInt Schrijf = FWriteText
-
-Start world = read
-
-////voer monadische I/O actie uit op de wereld:
-//doIO :: (IO a) *World -> *(a,*World)
-//doIO (IO f) world = f (world, Closed)
-
-// IO is een monad:
-instance return IO where
- return x = IO (\w fh = (x, w, fh))
-//instance >>= IO where
-// (>>=) (IO f) g = IO(\w = let (a, w1) = f w in doIO (g a) w1)
-
-//lees regel van de console:
-read:: IO String
-read = IO (\w fh -> ("", w, fh))
-
-/*//schrijf regel naar de console:
-write:: String -> IO Void
-write s = IO (\w = (Void, write` s w))
- where
- write`:: String *World -> *World
- write` s world
- # (io, world) = stdio world
- # io = fwrites s world
- # (_, world) = fclose io
- = world
-
-//open de file met gegeven filenaam en mode:
-open:: Filenaam Filemode -> IO (Maybe Filehandle)
-open s m = IO (\w = let (f1, w1) = openfh` s m w in (f1, (w1, f1)))
- where
- openfh`:: Filenaam Filemode *World -> (Maybe Filehandle, *World)
- openfh` s m world
- # (ok, file, world) = fopen s (toInt m) world
- | ok = (Just (Open (m, file)), world)
- | otherwise = (Nothing, world)
-
-//sluit de file met gegeven filenaam:
-close:: Filehandle -> IO Bool
-close fh = IO (\w = let (b1, w1) = close` fh w in (b1, (w1, Closed)))
- where
- close`:: Filehandle *World -> (Bool, *World)
- close` Closed world = (False, world)
- close` (Open (_, file)) world = fclose file world
-
-//bepaal of het lezen van de file klaar is:
-eof:: Filehandle -> IO Bool
-eof fh = IO (\w = let (b1, w1) = eof` fh w in (b1, (w1, Closed)))
- where
- eof`:: Filehandle *World -> (Bool, *World)
- eof` Closed world = (world, False)
- eaf`(Open (_, file)) world = fclose file
-
-//lees een regel van een file:
-readline:: Filehandle -> IO (Maybe String)
-readline fh = IO (\w = let r1 = readline` fh w in r1)
- where
- readline`:: Filehandle *World -> (Maybe String, (*World, Filehandle))
- readline` Closed world = (world, Nothing)
- readline` (Open (Schrijf, _)) world = (world, Nothing)
- readline` (Open (Lees, file)) world
- # (line, file) = sfreadline file
- = (Just line, (world, Open (Lees, file)))
-
-//schrijf een regel naar een file:
-writeline:: String Filehandle -> IO Bool
-writeline s fh = IO (\w = let r1 = writeline` s fh w in r1)
- where
- writeline`:: String Filehandle *World -> (Bool, (*World, Filehandle))
- writeline` line Closed world = (False, (world, Closed))
- writeline` line (Open (Lees, file)) world = (False, (world, (Open (Lees, file))))
- writeline` line (Open (Schrijf, file)) world
- # file = fwrites line file
- = (True, (world, file))*/
diff --git a/fp2/week2/mart/oldold/old/StdMaybeMonad.dcl b/fp2/week2/mart/oldold/old/StdMaybeMonad.dcl
deleted file mode 100644
index e9ebec1..0000000
--- a/fp2/week2/mart/oldold/old/StdMaybeMonad.dcl
+++ /dev/null
@@ -1,9 +0,0 @@
-definition module StdMaybeMonad
-
-import StdMonad
-
-:: Maybe a = Nothing | Just a
-
-instance return Maybe
-instance >>= Maybe
-instance fail Maybe
diff --git a/fp2/week2/mart/oldold/old/StdMaybeMonad.icl b/fp2/week2/mart/oldold/old/StdMaybeMonad.icl
deleted file mode 100644
index 1c6277d..0000000
--- a/fp2/week2/mart/oldold/old/StdMaybeMonad.icl
+++ /dev/null
@@ -1,10 +0,0 @@
-implementation module StdMaybeMonad
-
-import StdMonad
-
-:: Maybe a = Nothing | Just a
-
-instance return Maybe where return x = Just x
-instance >>= Maybe where >>= (Just x) f = f x
- >>= Nothing f = Nothing
-instance fail Maybe where fail = Nothing
diff --git a/fp2/week2/mart/oldold/old/StdMonad.dcl b/fp2/week2/mart/oldold/old/StdMonad.dcl
deleted file mode 100644
index cd1c654..0000000
--- a/fp2/week2/mart/oldold/old/StdMonad.dcl
+++ /dev/null
@@ -1,8 +0,0 @@
-definition module StdMonad
-
-class return c :: a -> c a
-class (>>=) infix 0 c :: (c a) (a -> c b) -> c b
-class fail c :: c a
-
-class Monad c | return, >>= c
-class MonadFail c | Monad, fail c
diff --git a/fp2/week2/mart/oldold/old/StdMonad.icl b/fp2/week2/mart/oldold/old/StdMonad.icl
deleted file mode 100644
index db193ab..0000000
--- a/fp2/week2/mart/oldold/old/StdMonad.icl
+++ /dev/null
@@ -1 +0,0 @@
-implementation module StdMonad
diff --git a/fp2/week2/mart/s4109503_s4498062_fp2_w2.tar.gz b/fp2/week2/mart/s4109503_s4498062_fp2_w2.tar.gz
new file mode 100644
index 0000000..587d742
--- /dev/null
+++ b/fp2/week2/mart/s4109503_s4498062_fp2_w2.tar.gz
Binary files differ