[Haskell-beginners] IO and purity

Shishir Srivastava shishir.srivastava at gmail.com
Sun Apr 26 09:59:55 UTC 2015


Hi,

Can someone please explain how IO operations do not fit in the pure
category of mathematical function in that they have to be implemented via
Monads.

For e.g. the getLine function has the type IOString and it reads the input
from the user. Now as I see it the output of getLine will always be same if
the input remain same (i.e. for input "X" getLine will always return "X" )
which is the constraint on mathematical functions.

Therefore I don't see why monads are necessary for implementing IO in pure
languages.

I can understand why Date and Random functions have be implemented via
monads because their output will always change.

Thanks,
Shishir
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150426/1b09638d/attachment.html>


More information about the Beginners mailing list