Skip to content

Instantly share code, notes, and snippets.

@ooharak
Created December 10, 2012 04:59
Show Gist options
  • Save ooharak/4248456 to your computer and use it in GitHub Desktop.
Save ooharak/4248456 to your computer and use it in GitHub Desktop.
An incomplete snippet of Haskell study
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