Overloaded record fields

Oliver Charles ollie at ocharles.org.uk
Mon Jun 24 16:40:32 CEST 2013


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20130624/eabdc4fe/attachment.pgp>


More information about the Glasgow-haskell-users mailing list