Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Time Travel in Haskell (a function's output is passed as a parameter to the same function) (community.livejournal.com)
5 points by amichail on April 10, 2007 | hide | past | favorite | 3 comments


Okay... how do you do this in Lisp? Also, PG, does Arc support Time Travel instructions? ;)


Fully reentrant continuations feel a lot like time travel.

In fact, I once overslept my first class because when my alarm went off and I woke up groggy, I shut off my alarm thinking "I'll just remember my current continuation and if I oversleep I'll call it back later with an error."


Doing it in Lisp would be exceedingly tricky, since, while most dialects have some sort of laziness construction, it's explicit, so you don't get the automatic evaluation order reduction that happens in Haskell.

(NB: Unless I'm wrong. I've never tried it, it's possible that there's some nice trick for it that just isn't occuring to me.)

It's unlikely that the situation is any different in Arc; Haskell is just fundamentally different from other languages (other than Clean), in that lazy evaluation is the default behavior. In Lisp you can ask to create a thunk and then ask to evaluate it later; in Haskell, everything is a thunk, and the compiler/runtime evaluates it when needed.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: