Created
December 10, 2012 04:59
-
-
Save ooharak/4248456 to your computer and use it in GitHub Desktop.
An incomplete snippet of Haskell study
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
module Sort | |
where | |
import IO | |
cat = bracket | |
(openFile "a.txt" ReadMode) | |
hClose | |
(\h -> docatloop h) | |
where docatloop h = do | |
iseof <- hIsEOF h | |
case iseof of | |
True -> return () | |
False -> do | |
line <- hGetLine h | |
putStr (line ++ "\n") | |
docatloop h | |
getfile = bracket | |
(openFile "a.txt" ReadMode) | |
hClose | |
(\h -> dogetfileloop h) | |
where | |
dogetfileloop::h->[a]->[a] | |
dogetfileloop h [] = [] | |
dogetfileloop h (xs) = let io = getoneline h | |
in case io of | |
Nothing -> xs | |
_ -> | |
getoneline h = do | |
iseof <- hIsEOF h | |
case iseof of | |
True -> Nothing | |
False -> hGetLine h | |
case iseof of | |
True -> xs | |
False -> do | |
dogetfileloop h (line:xs) | |
askname = do | |
putStrLn "Entrez votre nom:" | |
name <- getLine | |
case name of | |
"Simon" -> do putStrLn "Haskell c'est bon" | |
"Koen" -> do putStrLn "debugging Haskel is fun" | |
_ -> do putStrLn "How do you do " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment