Created
December 30, 2016 13:05
-
-
Save waynejo/dc493bac88a16b2d5b4d59e4df9f2e4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foldLString : (List String) -> String | |
foldLString [] = "" | |
foldLString (x :: xs) = x ++ "\n" ++ foldLString xs | |
readAndSave : IO () | |
readAndSave = do lines <- readToBlank | |
putStrLn "Enter file name:" | |
fileName <- getLine | |
writeFile fileName (foldLString lines) | |
pure () | |
subReadVectFile : (handle : File) -> IO (n ** Vect n String) | |
subReadVectFile handle = do Right x <- fGetLine handle | |
| Left err => pure (_ ** []) | |
isEnd <- fEOF handle | |
if (isEnd) | |
then pure (_ ** []) | |
else do (_ ** xs) <- subReadVectFile handle | |
pure(_ ** x :: xs) | |
readVectFile : (filename : String) -> IO (n ** Vect n String) | |
readVectFile filename = do Right h <- openFile filename Read | |
| Left err => pure (_ ** []) | |
result <- subReadVectFile h | |
closeFile h | |
pure(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment