Haskell Language Analisi e costruzione di un oggetto da input standard


Esempio

readFloat :: IO Float
readFloat =
    fmap read getLine


main :: IO ()
main = do
    putStr "Type the first number: "
    first <- readFloat

    putStr "Type the second number: "
    second <- readFloat

    putStrLn $ show first ++ " + " ++ show second ++ " = " ++ show ( first + second )

Ingresso:

Type the first number: 9.5
Type the second number: -2.02

Produzione:

9.5 + -2.02 = 7.48