[Haskell]
insufficiently laziness@pattern -- more counterintuitive stuff
S. Alexander Jacobson
alex at alexjacobson.com
Tue Mar 30 10:30:27 EST 2004
I would assume that this function:
foo list@(h:t) = list
is equivalent to
foo list = list
where (h:t)=list
But passing [] to the first generates an error
even though h and t are never used! Passing [] to
the second works just fine.
At this point, I sort of understand the reason for
MR and not having partially applied type synonyms,
but this seems entirely like an issue of syntactic
sugar....
FYI, I encountered this issue attempting to write
code that merges the content of two lists of tuples e.g.
merge left@((xL,yL):restL) right@((xR,yR):restR)
| left==[] = ....
I imagine this issue is fairly common so perhaps
its another idiom issue.
-Alex-
PS This code is part of a joinSets function for data.Sets
_________________________________________________________________
S. Alexander Jacobson mailto:me at alexjacobson.com
tel:917-770-6565 http://alexjacobson.com
More information about the Haskell
mailing list