| An anonymous user wrote on February 4th, 2007 at 08:36 pm |
Any Evaluation order?
Well, technically _|_ (undefined/bottom) throws a wrench in this. Well, perhaps it doesn't if you evaluate patterns top to bottom, left to right.
For example, the prelude definition of ||:
True || _ = True
False || x = x
This hardcodes the evaluation order of evaluating the left hand side first.
The more standard definition of ||:
True || True = True
True || False = True
False || True = True
False || False = False
This would allow the right hand side to optionally be evaluated first, allowing the left hand side to possibly non-terminate.
A possible, though costly, solution to this might be to do progressive-deepening execution. In other words, both sides are executed until enough information is known to provide a result for the entire expression.
For example, the prelude definition of ||:
True || _ = True
False || x = x
This hardcodes the evaluation order of evaluating the left hand side first.
The more standard definition of ||:
True || True = True
True || False = True
False || True = True
False || False = False
This would allow the right hand side to optionally be evaluated first, allowing the left hand side to possibly non-terminate.
A possible, though costly, solution to this might be to do progressive-deepening execution. In other words, both sides are executed until enough information is known to provide a result for the entire expression.
(Read Comments)