purescript/purescript-lazy

Guard against double force with an exception?

Opened this issue · 1 comments

If you use Lazy recursively, and make it too strict, you can wind up calling force inside of a force. Currently, this will loop forever (or blow the stack more likely), but should we guard against this and throw an exception? The compiler does this with recursive binding groups (which can appear anywhere), so this isn't really adding exceptions where there otherwise wouldn't be any.

garyb commented

Throwing sounds good to me - an infinite loop is no better than an error, and at least throwing will slightly demystify what the actual problem is.