[Haskell-beginners] IO and purity

Kim-Ee Yeoh ky3 at atamo.com
Sun Apr 26 11:52:09 UTC 2015


On Sun, Apr 26, 2015 at 4:59 PM, Shishir Srivastava <
shishir.srivastava at gmail.com> wrote:

> 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.
>

Notice that getLine is not a function. It is a value of type IO String.

In the misty dawn of Haskell, how you'd achieve the same thing as getLine
is to actually use Dialogue functions.

And yes, a value of type Dialogue is a bona fide function because Dialogue
is a type synonym for [Response] -> [Request].

You can read a bit about Haskell 1.2 and IO here:

http://r6.ca/blog/20110520T220201Z.html

Now Haskell 1.2 dates from 1992. Certainly it would be an experience
playing with it. Unfortunately, I know of no way to get hold of a compiler
or interpreter that old. You might want to query haskell-cafe.

Returning to getLine and monadic I/O, a question to contemplate is: how is
getLine different from an ordinary String, say "hello world"?

-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150426/17bd68f6/attachment.html>


More information about the Beginners mailing list