[Haskell-beginners] 'Simple' function

Rein Henrichs rein.henrichs at gmail.com
Wed Jun 10 18:55:22 UTC 2015


On Wed, Jun 10, 2015 at 11:15 AM Marcin Mrotek <marcin.jan.mrotek at gmail.com>
wrote:

> That's why, this is not a pure function because every time you call it, it
> may return a different string.
>

This is a common source of confusion. A value of type IO a for some a is
not an impure function because it is not a function. Its *evaluation* is
completely pure and referentially transparent: every time you evaluate
`getLine`, you get the same IO String value. The only observable difference
is under execution, but *we don't expect execution to be pure*: we only
expect evaluation to be pure.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150610/bc7bc991/attachment-0001.html>


More information about the Beginners mailing list