<div dir="ltr"><div>Hi, </div><div><br></div><div>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.</div><div><br></div><div>For e.g. the <font face="monospace, monospace">getLine </font>function has the type <font face="monospace, monospace">IOString </font><font face="arial, helvetica, sans-serif">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" </font><font face="monospace, monospace">getLine </font><font face="arial, helvetica, sans-serif">will always return "X" ) which is the constraint on mathematical functions.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Therefore I don't see why monads are necessary for implementing IO in pure languages.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">I can understand why </font><font face="monospace, monospace">Date </font><font face="arial, helvetica, sans-serif">and </font><font face="monospace, monospace">Random </font><font face="arial, helvetica, sans-serif">functions have be implemented via monads because their output will always change.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Thanks,</font></div><div><div class="gmail_signature"><div dir="ltr"><font color="#0b5394"><font style="background-color:rgb(255,255,255)"><font size="2" face="georgia, serif">Shishir </font></font></font><br></div></div></div>
</div>