Overloaded record fields

Erik Hesselink hesselink at gmail.com
Mon Jun 24 16:50:15 CEST 2013


It looks like this instance is partial. Note that the record field 'y'
is also a partial function in plain Haskell. I've always considered
this a misfeature, but perhaps fixing that is outside the scope of
this proposal.

Erik

On Mon, Jun 24, 2013 at 4:40 PM, Oliver Charles <ollie at ocharles.org.uk> wrote:
> On 06/24/2013 08:44 AM, Adam Gundry wrote:
>> Hi everyone,
>>
>> I am implementing an overloaded record fields extension for GHC as a
>> GSoC project. Thanks to all those who gave their feedback on the
>> original proposal! I've started to document the plan on the GHC wiki:
>>
>> http://hackage.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/Plan
>>
>> If you have any comments on the proposed changes, or anything is unclear
>> about the design, I'd like to hear from you.
>>
>> Thanks,
>>
>> Adam Gundry
>>
>> _______________________________________________
>> Glasgow-haskell-users mailing list
>> Glasgow-haskell-users at haskell.org
>> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
> The wiki page says:
>
> The base design has the following distinct components:
>
>   * A library class
>
>     class Has (r :: *) (f :: String) (t :: *) where
>       get :: r -> t
>
>   * A record declaration generates an instance declaration for each
>     field. For example
>
>     data T a = T1 { x :: a, y :: Bool }
>              | T2 { x :: a }
>
>     would generate
>
>     instance (t~a) => Has (T a) "x" t where
>       get (T1 x _) = x
>       get (T2 x)   = x
>     instance (t~Bool) => Has (T a) "y" t where
>       get (T1 _ y) = y
>
> Is this instance for "y" not partial? If it is, is that a problem?
> Perhaps I missed something that makes that instance total.
>
> - Ollie
>
>
>
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>



More information about the Glasgow-haskell-users mailing list