[Haskell-beginners] IO and purity

Jakob Holderbaum mailings at jakob.io
Sun Apr 26 10:16:08 UTC 2015


Hi Shishir,

I explain it to myself as the nondeterministic behavior of the user which would lead to the impurity.

>From the perspective of the programm, you just call a function without argument that returns a string.
And every call has the potential to return something totally different depending on the users behavior.

So what you called input is not the input in the sense of an functional argument which is the foundation of the definition of purity.

I am myself an absolute beginner in Haskell and Functional Thinking so I hope to get some constructive feedback on my mental image of this situation.

Cheers
Jakob

On 04/26/2015 11:59 AM, Shishir Srivastava wrote:
> 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
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>

-- 
Jakob Holderbaum, M.Sc.
Embedded Software Engineer

0176 637 297 71
http://jakob.io/
http://jakob.io/mentoring/
hi at jakob.io
@hldrbm



More information about the Beginners mailing list