Unfortunately, I/O is probably the worst example of a monad there is. The next worse example is the state monad. The "Maybe" monad is much better example, especially for beginners.

You might like the Clean language more, where I/O is done with unique types. And then, once you get tired of carrying this "world parameter", you might say to yourself, "Why don't we tuck this boilerplate away into a function, so that we don't have to mess with it all the time?" Bingo, there's the usefulness of monads.

And to answer the OP's question, there is essentially no reasonable reason why anyone would use monads in Perl. Besides the fact that Perl's syntax makes it heavyweight and messy, its lack of static typing makes it hard to program in a functional manner.


In reply to Re^2: Is it worth using Monads in Perl ? and what the Monads are ? by Anonymous Monk
in thread Is it worth using Monads in Perl ? and what the Monads are ? by rootcho

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.