Haskell’s Solution
Side effects are recorded in the type!
readFile :: String -> IO String
writeFile :: String -> String -> IO ()
So the type of tick is
tick :: String -> IO Int
and tick == tick is ill-typed.
Performs I/O
and delivers
a String.
IO is a monad --
more later!
Föregående bild
Nästa bild
Tillbaka till första bilden
Visa grafisk version