
On Wednesday, 13. July 2011 00:03:44 Ertugrul Soeylemez wrote:
I had some hopes that chaining functions monad-style would ease my pain. I might be on the wrong track though, feel free to tell me so.
You probably are, because the usefulness of monads depends a good deal on syntax. ECMA-based languages like JavaScript, ActionScript, Haxe, etc. have a terrible syntax for anonymous functions.
To give you an alternative, this really sounds like you're looking for a continuation-based solution. Continuation passing style could really solve your problem elegantly even in JavaScript.
Right. It did. It sometimes doens't work to define the callback *after* the function which needs the callback. It is not always easy to find out *when* things need to be defined in javascript. Luckily in Haskell there is no "when". Still in most cases it works and the code looks like regular procedural code, where control flows from top to bottom. And I could nicely write code where the callback makes another callback etc. Thanks. -- Martin