Monads don’t compose, effects do. ‘IO a’ works great until until you need to add another effect, for example ‘Maybe’. Then you need to bring in monad transformers and create your own monad combining the two, then rewrite all your code to lift the effects from one monad to the other. And you have to do this every time you want to add a new effect.
ChadNauseam|2 years ago
This is even worse in Rust, which requires you to have a separate implementation for every effect as well (since it doesn't have higher kinded types)
nyssos|2 years ago
This is more a weakness of Haskell's standard library (which is despite its reputation not very friendly to category theory) than an inherent problem with monads. A more general `map` would look something like this
but this would require somewhat better type-level programming support for the ergonomics to work out.