"aj" == S Alexander Jacobson <alex@alexjacobson.com> writes:
aj> I would assume that this function: aj> foo list@(h:t) = list aj> is equivalent to aj> foo list = list aj> where (h:t)=list aj> But passing [] to the first generates an error aj> even though h and t are never used! Passing [] to aj> the second works just fine. The @-pattern behaves exactly as specified in the Haskell report under "3.17.2 Informal Semantics of Pattern Matching": 9. Matching an as-pattern var@apat against a value v is the result of matching apat against v, augmented with the binding of var to v. If the match of apat against v fails or diverges, then so does the overall match. And the following translation is suggested in the preceding section: Patterns of the form var@pat are called as-patterns, and allow one to use var as a name for the value being matched by pat. For example, case e of { xs@(x:rest) -> if x==0 then rest else xs } is equivalent to: let { xs = e } in case xs of { (x:rest) -> if x==0 then rest else xs } -Peter