mirror of
https://github.com/ilyakooo0/Idris-dev.git
synced 2024-09-21 22:17:19 +03:00
bf4bdcc31e
Old names still work with a deprecation warning. New names are intended to be more self consistent.
31 lines
938 B
Idris
31 lines
938 B
Idris
module Main
|
|
|
|
mwhile : (test : IO Bool) -> (body : IO ()) -> IO ()
|
|
mwhile t b = do v <- t
|
|
case v of
|
|
True => do b
|
|
mwhile t b
|
|
False => return ()
|
|
|
|
dumpFile : String -> IO ()
|
|
dumpFile fn = do { Right h <- openFile fn Read
|
|
mwhile (do { -- putStrLn "TEST"
|
|
x <- fEOF h
|
|
return (not x) })
|
|
(do { Right l <- fGetLine h
|
|
putStr l })
|
|
closeFile h }
|
|
|
|
main : IO ()
|
|
main = do { Right h <- openFile "testfile" Write
|
|
fPutStr h "Hello!\nWorld!\n...\n3\n4\nLast line\n"
|
|
closeFile h
|
|
putStrLn "Reading testfile"
|
|
Right f <- readFile "testfile"
|
|
putStrLn f
|
|
putStrLn "---"
|
|
dumpFile "testfile"
|
|
putStrLn "---"
|
|
}
|
|
|