4 ms·
Probably a lot like javascript. with_monad(foo){ var x = bar(); baz(x); } where foo includes a definition of bind and return (return shoul
by jhpriestley 16y ago
Probably a lot like javascript.
with_monad(foo){
var x = bar();
baz(x);
}
where foo includes a definition of bind and return (return should be renamed, there is already a return in js). Subcalls like baz(x) would be interpreted within the same monad.
Basically you would just make semicolon a function with dynamic extent, rather than a language builtin.
I don't know if it would be possible to monadize functions which use break, continue, or return. While and if would have to be special cased.
- olavk 16y agoBut wouldn't that require that all calls inside the with_monad block is of the same monad type? Wouldn't the syntax need a way of distinguishing between monadic and non-monadic operations (like using "let" rather than "<-" in Haskells do-syntax)?