Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> one can write reasonable code abstracted over it

Don't you think that at least in a strict language, this would be rather over-abstraction or abstracting for the sake of abstraction?



Not really. I think you're confusing Haskell's purity, which makes it necessary to write monadic code, with its monad syntax, which makes it easy.


I think I am not. Monads has nothing to do with "purity" - Erlang is a pure-functional language but there are no monads.

Monad make sense only within a language with Normal (instead of Applicative) order of evaluation, to ensure that one computation (or action) "finishes" (being reduced to a value) before another (>>= and >>). return is for the type-checker.


That's a very specific way of thinking about monads. Sure, they enforce ordering in a language where you may want to do that. But they're also any ADT equipped with a generalized map (that we happen to call >>= or bind) that commutes nicely. I don't think about my list operations using bind as about ordering computation; I think about them as transforming data in a way that is a little harder to do with more traditional list operations. Same with set, maybe, etc. The ordering feature of monads is more about IO actions than it is about monads in themselves.

All I'm saying is that monads are a useful abstraction regardless of whether or not they are used to encapsulate effects. I use Traversables, which have a bind operation, all the time in Scala, and it is an effectful language.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: