
14 Jul
2010
14 Jul
'10
6 a.m.
On Wed, Jul 14, 2010 at 10:39:23AM +0100, Tom Doris wrote:
Can someone give an explanation of the use of record syntax in newtype declarations that helps one understand how it's meant to be interpreted? I understand the "facts" according to the language definition, but I just don't see why this notation was used; does it have any relationship with records?
Yes, the reason this notation is used is that it corresponds exactly to defining a record containing one field. Declaring field names in a record really just gives you some projection functions to get the fields out (and also some pattern-matching magic); declaring a field name in a newtype gives you a projection function to unwrap the newtype. Does that help? -Brent