From aebffcc1c786e8cea15fff6f324bf71fc37cbb37 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Fri, 24 Apr 2015 09:10:46 +0200 Subject: updated practicum files --- files/practicum/StdIOMonad.dcl | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 files/practicum/StdIOMonad.dcl (limited to 'files/practicum/StdIOMonad.dcl') diff --git a/files/practicum/StdIOMonad.dcl b/files/practicum/StdIOMonad.dcl new file mode 100644 index 0000000..a37a979 --- /dev/null +++ b/files/practicum/StdIOMonad.dcl @@ -0,0 +1,39 @@ +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 -- cgit v1.2.3