wiki:RecordPatternMatching

Version 2 (modified by malcolm.wallace@…, 8 years ago) (diff)

--

Section 3.17.2, "Informal Semantics of Pattern Matching", is a bit vague on matching record patterns. For example, see this GHC bug report:

http://cvs.haskell.org/trac/ghc/ticket/246

There are two possible ways forward:

  • Clarify the description to ratify GHC's behaviour, i.e. record fields are matched in the order written in the datatype. Pros: this is easier to implement, Cons: it is not quite as intuitive for the programmer.
  • Clarify the description to specify that fields are matched in the order written in the pattern.

The errata list for the Revised H'98 Report resolved this issue (after discussion on the haskell mailing list), in favour of the second option - i.e. the pattern order, not the declaration order.