|
|
|
|
|
by pcwalton
3800 days ago
|
|
An oversimplified version: the monad rules/type signature only allow for possibly-recursive sequences of statements. That admits straight-line code as well as if, while, and for. But it doesn't allow for any exceptional loop exits (more formally, doesn't allow for any backwards edge from node A to B unless A postdominates B). There are ways to transform code to allow this to work (there has to be, since Haskell is Turing-complete), but it's not straightforward. |
|
The Option monad already is a sort of early return. Inside of monadic combinators, you use the monad for control flow instead of those statements. Seems fine to me, though admittedly my Type Theory Wizardry isn't the strongest.