User loginNavigation 
Monads in various languages
While working on implementing monads and comprehensions, I ran into a complication in translating comprehensions to their underlying monadic expressions. Looking at other languages for insight, I realized that all languages which make use of monads use type deduction and that this feature appears to be critical to making comprehensions work.
To translate a comprehension for a monad M, you need to translate expressions like [x+1  x < xm] where you know that xm:M(int) for a statically unknown monad M. But how do you typecheck "x+1", which requires that x is a numeric type? Nothing in this expression explicitly indicates that x is numeric. Thus one would need type deduction and explicit universal quantification with matching to deduce that x is numeric, or ugly explicit type specification on comprehensions like [x+1  x::int < xm]. My conjecture is that this is why monads happen to be widelyused only in languages supporting HindleyMilner type deduction, while traditional languages use imperative constructs like iterators, exceptions and sideeffects for roughly similar tasks. Monads would be awfully inconvenient without this syntactic sugar, which happens to rely on a rather narrowlyavailable language feature. I would appreciate any counterarguments on this conjecture. Also any references to non HindleyMilner languages supporting monads conveniently. By Tim Sweeney at 20040929 23:05  LtU Forum  previous forum topic  next forum topic  other blogs  4947 reads

Browse archivesActive forum topicsNew forum topics 
Recent comments
4 hours 30 min ago
18 hours 26 min ago
1 week 4 days ago
2 weeks 11 hours ago
2 weeks 19 hours ago
2 weeks 1 day ago
2 weeks 1 day ago
2 weeks 2 days ago
2 weeks 2 days ago
2 weeks 2 days ago