diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2018-10-03 16:35:09 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2018-10-04 15:37:58 +0100 |
commit | 2f09753f96207c12efd43090f5de55b05aef35d3 (patch) | |
tree | 4093c0be62785abc174e1ff2e1ea781cc07789b4 /libraries | |
parent | 37ef7031b95c97e7c8bc1d14bc95554a3bac2873 (diff) | |
download | haskell-2f09753f96207c12efd43090f5de55b05aef35d3.tar.gz |
Distinguish Inferred from Specified tyvars
In a declared type we need to distinguish between Inferred
and Specified type variables. This was exposed by Trac #15592.
See Note [Work out final tyConBinders] in TcTyClsDecls.
I had to change the definition of HasField in GHC.Records to
class HasField x r a | x r -> a where
so as to have an /inferred/ kind argument rather than a
specfied one. So
HasField :: forall {k}. k -> * -> * -> Constraint
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/base/GHC/Records.hs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libraries/base/GHC/Records.hs b/libraries/base/GHC/Records.hs index 43c3931e86..3b1a4c2834 100644 --- a/libraries/base/GHC/Records.hs +++ b/libraries/base/GHC/Records.hs @@ -29,6 +29,13 @@ module GHC.Records -- | Constraint representing the fact that the field @x@ belongs to -- the record type @r@ and has field type @a@. This will be solved -- automatically, but manual instances may be provided as well. -class HasField (x :: k) r a | x r -> a where +-- +-- HasField :: forall {k}. k -> * -> * -> Constraint +-- getField :: forall {k} (x::k) r a. HasField x r a => r -> a +-- NB: The {k} means that k is an 'inferred' type variable, and +-- hence not provided in visible type applications. Thus you +-- say getField @"foo" +-- not getField @Symbol @"foo" +class HasField x r a | x r -> a where -- | Selector function to extract the field from the record. getField :: r -> a |