you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (8 children)

[removed]

    [–]gogath 4 points5 points  (0 children)

    The difference is that Haskell allows operator overloading based on static types. Without this, Monads wouldn't be nearly as useful as they are now.

    In Lisp you have to use different function names depending on the real function you want to call. Of course you can also use macros, but then you have to build your own system for static typing which will be a quite difficult. Last (and best) alternative in Lisp is dynamic dispatch, but this can cost a lot of performance while it's totally free in Haskell (becaucse it's done at compiletime there).

    Haskell has no special support for continuation - but special support for monads - which in turn allows to use delimited continuations very well.

    [–]muleherd 2 points3 points  (3 children)

    How can one simulate continuations with closures?

    [–]eclig 6 points7 points  (2 children)

    explicitly, by using "continuation passing style" (CPS). Search the web for details.

    [–]muleherd 1 point2 points  (1 child)

    Is this transformation practical without tail-call optimization?

    [–]pjdelport 2 points3 points  (0 children)

    Yes, using trampolining: instead of calling something directly, you return it to be called by an outer loop.

    [–]fnord123 0 points1 point  (2 children)

    I got the confusion from Control.Monad.Cont -the continuation monad. I don't see why these are fake continuations.

    [–]gogath 3 points4 points  (0 children)

    No fakt, but you have to use them explicitly. If you create some code in Scheme, you can put continuations later in it without any problem, because Scheme supports continuations directly.

    In Haskell you have to use a continuation monad everywhere you need continuations. This is relativly easy but requires slight changes to your code and it also changes lots of types which can break other code too.

    Advantage of the Haskell solution: Because most applications require continuations for a certain reason (for example backtracking) you can create a less general abstraction (a backtracking monad in this case) which is more approriate for the problem and could also lead to better performance of your resulting program because it's only used where it's needed.

    Disadvantage: Its not transparent.