Kapitel 1: Haskell in einer Nußschale hugs Hello ghc Hello.lhs > import Prelude hiding ( putStrLn, getLine ) > putStrLn :: String -> IO () > putStrLn [] = putChar '\n' > putStrLn (c : s) = putChar c >> putStrLn s > getLine :: IO String > getLine = getChar >>= \ c -> > if c == '\n' then > return "" > else > getLine >>= \ s -> > return (c : s) > getLine' :: IO String > getLine' = do c <- getChar > if c=='\n' then return "" > else do s <- getLine' > return (c : s) > main :: IO () > main = putStrLn "hello world" Testausdrücke: getLine >>= putStrLn putStr "Eingabe: " >> getLine >>= \ line -> putStrLn ("Ausgabe: " ++ line)