+++ /dev/null
-module ReturnEnBind\r
-\r
-import StdEnv, Random\r
-\r
-Start = 42\r
-\r
-(bind1) infix 0 :: (St s a) (a -> (St s b)) -> St s b\r
-//(bind1) infix 0 :: (s -> *(a,s)) (a -> (a -> *(a,s))) -> (s -> *(b,s))\r
-(bind1) f1 f2 = \st0 f2 (fst (f1 st0) (snd (f1 st0))\r
-// (r, st1) = f1 st0\r
-//(bind) f f2 :== \st0 -> let (r,st1) = f st0\r
-// in f2 r st1\r
-\r
-\r
-som2 :: (RandomSeed -> (Int,RandomSeed))\r
-som2 ...\r
-\r
-seqList1 :: [St s a] -> St s [a]\r
-seqList1 ...\r
+++ /dev/null
-module EchoMonad\r
-\r
-import StdString // expliciete import uit StdEnv om nameclash met StdFunc / StdIOMonad te voorkomen\r
-import StdIOMonad\r
-import StdMaybeMonad\r
-\r
-Start :: *World -> (Void,*World)\r
-Start world = doIO echo world\r
-\r
-echo :: IO Void\r
-echo = read >>= \regel ->\r
- if (regel == "\n")\r
- (return Void) \r
- (write regel >>= \_ -> echo)\r
\r
// Deze module verpakt een aantal StdFile functies in een monadische jas\r
\r
-import StdMonad, StdMaybeMonad\r
+import StdMonad, StdMaybe\r
\r
:: IO a\r
:: *W\r
:: Void = Void\r
:: Filemode = Lees | Schrijf\r
:: Filenaam :== String\r
-:: Filehandle\r
+:: Filehandle :== String\r
\r
// voer monadische I/O actie uit op de wereld:\r
doIO:: (IO a) *World -> *(a, *W)\r
write :: String -> IO Void\r
\r
// open de file met gegeven filenaam en mode:\r
-//open :: Filenaam Filemode -> IO (Maybe Filehandle)\r
+open :: Filenaam Filemode -> IO (Maybe Filehandle)\r
\r
// sluit de file met gegeven filenaam:\r
-//close :: Filehandle -> IO Bool\r
-//\r
-//// bepaal of het lezen van de file klaar is:\r
-//eof :: Filehandle -> IO Bool\r
-//\r
-//// lees een regel van een file:\r
-//readline :: Filehandle -> IO (Maybe String)\r
-//\r
-//// schrijf een regel naar een file:\r
-//writeline :: String Filehandle -> IO Bool\r
+close :: Filehandle -> IO Bool\r
+\r
+// bepaal of het lezen van de file klaar is:\r
+eof :: Filehandle -> IO Bool\r
+\r
+// lees een regel van een file:\r
+readline :: Filehandle -> IO (Maybe String)\r
+\r
+// schrijf een regel naar een file:\r
+writeline :: String Filehandle -> IO Bool\r
implementation module StdIOMonad\r
\r
-// Deze module verpakt StdFile in een monadische jas\r
-\r
import StdBool\r
import StdEnum\r
import StdFile\r
:: Filenaam :== String\r
:: Filehandle :== String\r
\r
+// Conversion from our filemodes to StdFile filemodes\r
instance toInt Filemode where\r
toInt Lees = FReadText\r
toInt Schrijf = FWriteText\r
\r
-//voer monadische I/O actie uit op de wereld:\r
+// Apply the monadic program on the world\r
doIO:: (IO a) *World -> *(a, *W)\r
doIO (IO f) w = f (w, [])\r
\r
+// Lift the value out of the monadic domain\r
unIO:: (IO a) -> *W -> *(a, *W)\r
unIO (IO f) = f \r
\r
-// IO is een monad:\r
instance return IO where\r
return x = IO (\w -> (x, w))\r
instance >>= IO where\r
(>>=) (IO f) g = IO (\w = let (a, w1) = f w in unIO (g a) w1)\r
\r
-//Start world = doIO (read >>= (\w = return w)) (world, "")\r
-//Start world = doIO (open "camilt.txt" Lees) (world, "")\r
-//Start world = doIO (read >>= (\w = read)) (world, "")\r
-\r
+// Read one line from the console\r
read:: IO String\r
read = IO read`\r
where\r
# (_, world) = fclose io world\r
= (line, (world, s))\r
\r
-// schrijf regel naar de console:\r
+// Write a line from the console\r
write :: String -> IO Void\r
write s = IO (write` s)\r
where\r
# (_, world) = fclose io world\r
= (Void, (world, s))\r
\r
-\r
-Start world = doIO (\r
- open "camil.txt" Lees >>= \r
- \y = eof "camil.txt") world\r
-\r
-// open de file met gegeven filenaam en mode:\r
-find:: Filehandle *[*(Filehandle, *File)] -> (Maybe *(Filehandle, *File), *[*(Filehandle, *File)]) \r
-find fh fs\r
-# (fhs, fis) = unzip fs\r
-# fhsC = zip2 [0..length fhs] fhs\r
-# index = [(i, h) \\ (i, h) <- fhsC | h == fh]\r
-| length index == 0 = (Nothing, zip2 fhs fis)\r
-# index = fst (hd index)\r
-# (fis1, fis2) = splitAt index fis\r
-# (fhs1, fhs2) = splitAt index fhs\r
-# (thefile, fis2) = splitAt 1 fis2\r
-# (thehandle, fhs2) = splitAt 1 fhs2\r
-= (Just (hd thehandle, hd thefile), zip2 (fhs1 ++ fhs2) (fis1 ++ fis2))\r
-\r
-\r
+// Open a file\r
open:: Filenaam Filemode -> IO (Maybe Filehandle)\r
open s m = IO (open` s m)\r
where\r
# (ok, file, world) = fopen fp (toInt m) world\r
= (Just fp, (world, [(fp, file):fs]))\r
\r
-// sluit de file met gegeven filenaam:\r
+// Close a file. If the file can't be closed by the system the program will\r
+// abort\r
close:: Filehandle -> IO Bool\r
close fh = IO (close` fh)\r
where\r
close`:: Filehandle *W -> *(Bool, *W)\r
close` fp (world, fs)\r
- # (currentfiletuple, fs) = find fp fs\r
+ # (currentfiletuple, fs) = getFH fp fs\r
| isNothing currentfiletuple = (False, (world, fs))\r
# (currentfh, currentfile) = fromJust currentfiletuple\r
# (ok, world) = fclose currentfile world\r
| otherwise = (True, (world, fs))\r
\r
\r
-// bepaal of het lezen van de file klaar is:\r
+// Determine if the file is at the end. This will abort when the file is not\r
+// open or error if the file is not opened for reading.\r
eof :: Filehandle -> IO Bool\r
eof fh = IO (eof` fh)\r
where \r
eof`:: Filehandle *W -> *(Bool, *W)\r
eof` fp (world, fs)\r
- # (currentfiletuple, fs) = find fp fs\r
+ # (currentfiletuple, fs) = getFH fp fs\r
| isNothing currentfiletuple = abort "Can't do eof on non-existing file"\r
# (currentfh, currentfile) = fromJust currentfiletuple\r
# (ok, file) = fend currentfile\r
= (ok, (world, [(currentfh, file):fs]))\r
\r
-// lees een regel van een file:\r
-//readline :: Filehandle -> IO (Maybe String)\r
-\r
+// Read one line from a file (including newline). This will abort when the file\r
+// is not open or error if the file is not opened for reading.\r
+readline :: Filehandle -> IO (Maybe String)\r
+readline fh = IO (readline` fh)\r
+ where\r
+ readline` :: Filehandle *W -> *(Maybe String, *W)\r
+ readline` fh (world, fs)\r
+ # (currentfiletuple, fs) = getFH fh fs\r
+ | isNothing currentfiletuple = abort "File not open"\r
+ # (currentfh, currentfile) = fromJust currentfiletuple\r
+ # (s, currentfile) = freadline currentfile\r
+ = (Just s, (world, [(currentfh, currentfile):fs]))\r
\r
-// schrijf een regel naar een file:\r
+// Write one line from a file (will not append newline). This will abort when\r
+// the file is not open or error if the file is not opened for writing.\r
writeline :: String Filehandle -> IO Bool\r
+writeline s fh = IO (writeline` s fh)\r
+ where\r
+ writeline` :: String Filehandle *W -> *(Bool, *W)\r
+ writeline` s fh (world, fs)\r
+ # (currentfiletuple, fs) = getFH fh fs\r
+ | isNothing currentfiletuple = abort "File not open"\r
+ # (currentfh, currentfile) = fromJust currentfiletuple\r
+ # currentfile = fwrites s currentfile\r
+ = (True, (world, [(currentfh, currentfile):fs]))\r
+\r
+// Gets the file associated with the filehandle given, this is done in a very\r
+// ugly way to retain uniqueness...\r
+getFH:: Filehandle *[*(Filehandle, *File)] ->\r
+ (Maybe *(Filehandle, *File), *[*(Filehandle, *File)]) \r
+getFH fh fs\r
+# (fhs, fis) = unzip fs\r
+# fhsC = zip2 [0..length fhs] fhs\r
+# index = [(i, h) \\ (i, h) <- fhsC | h == fh]\r
+| length index == 0 = (Nothing, zip2 fhs fis)\r
+# index = fst (hd index)\r
+# (fis1, fis2) = splitAt index fis\r
+# (fhs1, fhs2) = splitAt index fhs\r
+# (thefile, fis2) = splitAt 1 fis2\r
+# (thehandle, fhs2) = splitAt 1 fhs2\r
+= (Just (hd thehandle, hd thefile), zip2 (fhs1 ++ fhs2) (fis1 ++ fis2))\r
+++ /dev/null
-definition module StdListMonad\r
-\r
-import StdMonad\r
-\r
-instance return []\r
-instance >>= []\r
-instance fail []\r
+++ /dev/null
-implementation module StdListMonad\r
-\r
-import StdMonad\r
-\r
-instance return [] where return x = [x]\r
-instance >>= [] where >>= xs f = [y \\ x <- xs, y <- f x]\r
-instance fail [] where fail = []\r
+++ /dev/null
-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 ]
+++ /dev/null
-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 ]
+++ /dev/null
-definition module StdMaybeMonad\r
-\r
-import StdMonad\r
-\r
-:: Maybe a = Nothing | Just a\r
-\r
-instance return Maybe\r
-instance >>= Maybe\r
-instance fail Maybe\r
+++ /dev/null
-implementation module StdMaybeMonad\r
-\r
-import StdMonad\r
-\r
-:: Maybe a = Nothing | Just a\r
-\r
-instance return Maybe where return x = Just x\r
-instance >>= Maybe where >>= (Just x) f = f x\r
- >>= Nothing f = Nothing\r
-instance fail Maybe where fail = Nothing\r
--- /dev/null
+definition module Test
--- /dev/null
+implementation module Test\r
+\r
+import StdIOMonad\r
+\r
+// This assumes a file "camil.txt" and writes a line from it to "mart.txt"\r
+Start world = doIO (\r
+ open "camil.txt" Lees >>=\r
+ \_ = open "mart.txt" Schrijf >>=\r
+ \_ = readline "camil.txt" >>=\r
+ \l = writeline (fromJust l) "mart.txt" >>=\r
+ \_ = close "camil.txt" >>=\r
+ \_ = close "mart.txt"\r
+ ) world\r
+++ /dev/null
-module ToonFileMonad\r
-\r
-import StdArray, StdInt, StdString // expliciete imports van StdEnv om name-clash met StdFunc en StdIOMonad te voorkomen\r
-import StdIOMonad\r
-import StdMaybeMonad\r
-\r
-Start :: *World -> (Void,*World)\r
-Start world = doIO toon world\r
-\r
-toon :: IO Void\r
-toon = write "Voer een filenaam in: " >>= \_ ->\r
- read >>= \filenaam ->\r
- open (filenaam%(0,size filenaam-2)) Lees >>= \misschien_filehandle ->\r
- case misschien_filehandle of\r
- Nothing\r
- = write ("Kon " +++ filenaam +++ " niet openen.\n") >>= \_ ->\r
- return Void\r
- Just filehandle\r
- = toon_inhoud filehandle\r
-\r
-toon_inhoud :: Filehandle -> IO Void\r
-toon_inhoud filehandle\r
- = eof filehandle >>= \einde ->\r
- if einde\r
- (return Void)\r
- (readline filehandle >>= \misschien_regel ->\r
- case misschien_regel of\r
- Nothing = return Void\r
- Just regel = write regel >>= \_ -> toon_inhoud filehandle\r
- )\r
+++ /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
-definition module StdIOMonad\r
-\r
-// Deze module verpakt een aantal StdFile functies in een monadische jas\r
-\r
-import StdMonad, StdMaybeMonad\r
-\r
-:: IO a\r
-:: Void = Void\r
-:: Filemode = Lees | Schrijf\r
-:: Filenaam :== String\r
-:: *Filehandle\r
-\r
-// voer monadische I/O actie uit op de wereld:\r
-//doIO :: (IO a) *World -> *(a,*World)\r
-\r
-// IO is een monad:\r
-//instance return IO\r
-//instance >>= IO\r
-\r
-// lees regel van de console:\r
-read :: IO String\r
-\r
-/*\r
-// schrijf regel naar de console:\r
-write :: String -> IO Void\r
-\r
-// open de file met gegeven filenaam en mode:\r
-open :: Filenaam Filemode -> IO (Maybe Filehandle)\r
-\r
-// sluit de file met gegeven filenaam:\r
-close :: Filehandle -> IO Bool\r
-\r
-// bepaal of het lezen van de file klaar is:\r
-eof :: Filehandle -> IO Bool\r
-\r
-// lees een regel van een file:\r
-readline :: Filehandle -> IO (Maybe String)\r
-\r
-// schrijf een regel naar een file:\r
-writeline :: String Filehandle -> IO Bool*/\r
+++ /dev/null
-implementation module StdIOMonad\r
-\r
-//Deze module verpakt StdFile in een monadische jas\r
-\r
-import StdFile\r
-import StdMonad\r
-import StdMaybeMonad\r
-\r
-\r
-:: IO a = IO (*World Filehandle -> *(a, *World, Filehandle))\r
-:: Void = Void\r
-:: Filemode = Lees | Schrijf\r
-:: Filenaam :== String\r
-:: *Filehandle = None | FH *(Bool, Filemode, *File)\r
-\r
-toInt :: Filemode -> Int\r
-toInt Lees = FReadText\r
-toInt Schrijf = FWriteText\r
-\r
-Start world = read\r
-\r
-////voer monadische I/O actie uit op de wereld:\r
-//doIO :: (IO a) *World -> *(a,*World)\r
-//doIO (IO f) world = f (world, Closed)\r
-\r
-// IO is een monad:\r
-instance return IO where\r
- return x = IO (\w fh = (x, w, fh))\r
-//instance >>= IO where\r
-// (>>=) (IO f) g = IO(\w = let (a, w1) = f w in doIO (g a) w1)\r
-\r
-//lees regel van de console:\r
-read:: IO String\r
-read = IO (\w fh -> ("", w, fh))\r
-\r
-/*//schrijf regel naar de console:\r
-write:: String -> IO Void\r
-write s = IO (\w = (Void, write` s w))\r
- where\r
- write`:: String *World -> *World\r
- write` s world\r
- # (io, world) = stdio world\r
- # io = fwrites s world\r
- # (_, world) = fclose io\r
- = world\r
-\r
-//open de file met gegeven filenaam en mode:\r
-open:: Filenaam Filemode -> IO (Maybe Filehandle)\r
-open s m = IO (\w = let (f1, w1) = openfh` s m w in (f1, (w1, f1)))\r
- where\r
- openfh`:: Filenaam Filemode *World -> (Maybe Filehandle, *World)\r
- openfh` s m world\r
- # (ok, file, world) = fopen s (toInt m) world\r
- | ok = (Just (Open (m, file)), world)\r
- | otherwise = (Nothing, world)\r
-\r
-//sluit de file met gegeven filenaam:\r
-close:: Filehandle -> IO Bool\r
-close fh = IO (\w = let (b1, w1) = close` fh w in (b1, (w1, Closed)))\r
- where\r
- close`:: Filehandle *World -> (Bool, *World)\r
- close` Closed world = (False, world)\r
- close` (Open (_, file)) world = fclose file world\r
-\r
-//bepaal of het lezen van de file klaar is:\r
-eof:: Filehandle -> IO Bool\r
-eof fh = IO (\w = let (b1, w1) = eof` fh w in (b1, (w1, Closed)))\r
- where\r
- eof`:: Filehandle *World -> (Bool, *World)\r
- eof` Closed world = (world, False)\r
- eaf`(Open (_, file)) world = fclose file\r
-\r
-//lees een regel van een file:\r
-readline:: Filehandle -> IO (Maybe String)\r
-readline fh = IO (\w = let r1 = readline` fh w in r1)\r
- where\r
- readline`:: Filehandle *World -> (Maybe String, (*World, Filehandle))\r
- readline` Closed world = (world, Nothing)\r
- readline` (Open (Schrijf, _)) world = (world, Nothing)\r
- readline` (Open (Lees, file)) world\r
- # (line, file) = sfreadline file\r
- = (Just line, (world, Open (Lees, file)))\r
-\r
-//schrijf een regel naar een file:\r
-writeline:: String Filehandle -> IO Bool\r
-writeline s fh = IO (\w = let r1 = writeline` s fh w in r1)\r
- where\r
- writeline`:: String Filehandle *World -> (Bool, (*World, Filehandle))\r
- writeline` line Closed world = (False, (world, Closed))\r
- writeline` line (Open (Lees, file)) world = (False, (world, (Open (Lees, file))))\r
- writeline` line (Open (Schrijf, file)) world\r
- # file = fwrites line file\r
- = (True, (world, file))*/\r
+++ /dev/null
-definition module StdMaybeMonad\r
-\r
-import StdMonad\r
-\r
-:: Maybe a = Nothing | Just a\r
-\r
-instance return Maybe\r
-instance >>= Maybe\r
-instance fail Maybe\r
+++ /dev/null
-implementation module StdMaybeMonad\r
-\r
-import StdMonad\r
-\r
-:: Maybe a = Nothing | Just a\r
-\r
-instance return Maybe where return x = Just x\r
-instance >>= Maybe where >>= (Just x) f = f x\r
- >>= Nothing f = Nothing\r
-instance fail Maybe where fail = Nothing\r
+++ /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