Haskell Language Analizar y construir un objeto desde la entrada estándar


Ejemplo

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 )

Entrada:

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

Salida:

9.5 + -2.02 = 7.48