
27 Mar
2008
27 Mar
'08
2:32 p.m.
On Thu, Mar 27, 2008 at 2:18 PM, Claude Heiland-Allen
The combination of (-+) and h is too strict, this modification works:
(-+) :: a -> List a -> List a x -+ ~(List y) = List(f) where -- lazy pattern match
f 0 = x f k = y(k-1)
More to the point, if List is declared as: newtype List a = List (Integer -> a) Instead of with "data", it also works. The problem, as was stated, was that -+ is too strict. That is, without the ~ there, -+ evaluates its right argument to make sure it's not _|_ (that is the only other possibility in this case), and then proceeds with the rest of the function. So in: h x = first x -+ h (rest X) This first evaluates the recursive call, which will evaluate the recursive call, which ... Luke