3 ms·
You've probably been using IO monads as long as you've been programming: [Unix pipes as IO monads](https://www.okmij.org/ftp/Computation/monadic-shell.html http
by ipnon 5y ago
You've probably been using IO monads as long as you've been programming: [Unix pipes as IO monads](https://www.okmij.org/ftp/Computation/monadic-shell.html https://www.okmij.org/ftp/Computation/monadic-shell.html)
- brigandish 5y ago> cat v | cmd is cmd < v I have never seen an `is` operator in a shell so my understanding stopped right there, which is a pity as I felt I was getting somewhere.
- jcranmer 5y agoWhat it's saying is that the shell command `cat v | cmd` is equivalent to `cmd < v`--if you look carefully, the 'is' is in a different typeface (a serif font) than the commands (monospace).
- brigandish 5y agoAh, my mistake (or my poor, abused laptop leering eyes). Thanks, I thought I was being introduced to some abstruse shell programming on top of monads!
- ipnon 5y agoThe monad as used in Haskell is really just a functional replacement for the semicolon: `doFoo(); logBar(); requestBaz()` in Haskell is `doFoo >> logBar >> requestBaz`. If you want to get really fancy you can pipe the inputs: `doFoo | logBar | requestBaz` becomes `doFoo >>= logBar >>= requestBaz`. Haskell suffers from the fact that endless mathematical analysis is enjoyable to a certain breed of programmer known as the "mathematician".
- tremon 5y agoWhat you're saying applies to the IO Monad only, using the IO side-effect for sequencing purposes. I'm not sure is applies to the myriad of other monads available in Haskell.
- _y5hn 5y agoIt's not that far off, if you think of side-effects / any magical processing happening at evaluation per bind-function (semi-colon ;). It's so because monads follow the exact same pattern by definition, but the different types of monads just inject some additional behaviour and constraints as well. Different patterns from this are no longer monadic. The "magic" part of this is why different types of monads don't compose well. Of course, this is overly simplified but might help for understanding.
- usrbinbash 5y ago> `cat v | cmd` is equivalent to `cmd < v` https://askubuntu.com/questions/172982/what-is-the-difference-between-redirection-and-pipe https://askubuntu.com/questions/172982/what-is-the-differenc...