Records (was Re: [Haskell] Improvements to GHC)
Keean Schupke
k.schupke at imperial.ac.uk
Thu Nov 24 10:30:46 EST 2005
you can always do:
case (field1 record,field2 record, field3 record ...) of
(pat1,pat2,pat3) ->
_ ->
Which lets you pattern match on fields independantly of their
position in the record.
Keean.
David Roundy wrote:
>On Wed, Nov 23, 2005 at 02:58:43PM +0100, Wolfgang Jeltsch wrote:
>
>
>>Am Mittwoch, 23. November 2005 14:22 schrieb David Roundy:
>>
>>
>>>On Tue, Nov 22, 2005 at 02:32:47PM +0000, Rob Ennals wrote:
>>>[...]
>>>
>>>
>>>>7. Unordered records: yep (if I understand the problem correctly)
>>>>
>>>>
>...
>
>
>>You can just omit the data constructors from the module's export list.
>>
>>
>
>Yes, you can do that if you don't want to allow pattern matching. That's
>an acceptable solution for truly "exported" (i.e. opaque) data, but for
>internal data structures I would like to allow pattern matching without
>allowing positional matching (or constructing). Too many times I've had to
>go through the entire code adding an extra "_" to each pattern match, and
>each time there's a possibility you'll add it in the wrong spot. I could
>do this with coding guidelines, but I'd prefer to have the compiler enforce
>this.
>
>
More information about the Haskell
mailing list