diff options
author | Baldur Blöndal <baldurpet@gmail.com> | 2020-05-08 02:43:54 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-05-13 20:06:06 -0400 |
commit | df021fb15bcef313f30e772997bcb263c8f34078 (patch) | |
tree | 93b59cb52e142c9f9bbe35d38d6051f31cdf80ca | |
parent | b17574f74173d0fa83b0def070dcba51b710be2e (diff) | |
download | haskell-df021fb15bcef313f30e772997bcb263c8f34078.tar.gz |
Document (->) using inferred quantification for its runtime representations.
Fixes #18142.
-rw-r--r-- | compiler/GHC/Builtin/Types/Prim.hs | 18 | ||||
-rw-r--r-- | compiler/GHC/Core/Coercion.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Core/TyCo/Rep.hs | 5 | ||||
-rw-r--r-- | compiler/GHC/Core/Type.hs | 5 |
4 files changed, 26 insertions, 6 deletions
diff --git a/compiler/GHC/Builtin/Types/Prim.hs b/compiler/GHC/Builtin/Types/Prim.hs index e138780c44..ecf166e402 100644 --- a/compiler/GHC/Builtin/Types/Prim.hs +++ b/compiler/GHC/Builtin/Types/Prim.hs @@ -399,9 +399,23 @@ funTyConName = mkPrimTyConName (fsLit "->") funTyConKey funTyCon -- | The @(->)@ type constructor. -- -- @ --- (->) :: forall (rep1 :: RuntimeRep) (rep2 :: RuntimeRep). --- TYPE rep1 -> TYPE rep2 -> * +-- (->) :: forall {rep1 :: RuntimeRep} {rep2 :: RuntimeRep}. +-- TYPE rep1 -> TYPE rep2 -> Type -- @ +-- +-- The runtime representations quantification is left inferred. This +-- means they cannot be specified with @-XTypeApplications@. +-- +-- This is a deliberate choice to allow future extensions to the +-- function arrow. To allow visible application a type synonym can be +-- defined: +-- +-- @ +-- type Arr :: forall (rep1 :: RuntimeRep) (rep2 :: RuntimeRep). +-- TYPE rep1 -> TYPE rep2 -> Type +-- type Arr = (->) +-- @ +-- funTyCon :: TyCon funTyCon = mkFunTyCon funTyConName tc_bndrs tc_rep_nm where diff --git a/compiler/GHC/Core/Coercion.hs b/compiler/GHC/Core/Coercion.hs index a95c16c372..7294209730 100644 --- a/compiler/GHC/Core/Coercion.hs +++ b/compiler/GHC/Core/Coercion.hs @@ -292,7 +292,9 @@ tidyCoAxBndrsForUser init_env tcvs Note [Function coercions] ~~~~~~~~~~~~~~~~~~~~~~~~~ Remember that - (->) :: forall r1 r2. TYPE r1 -> TYPE r2 -> TYPE LiftedRep + (->) :: forall {r1} {r2}. TYPE r1 -> TYPE r2 -> TYPE LiftedRep +whose `RuntimeRep' arguments are intentionally marked inferred to +avoid type application. Hence FunCo r co1 co2 :: (s1->t1) ~r (s2->t2) diff --git a/compiler/GHC/Core/TyCo/Rep.hs b/compiler/GHC/Core/TyCo/Rep.hs index 4ac731bc07..46a6cdee01 100644 --- a/compiler/GHC/Core/TyCo/Rep.hs +++ b/compiler/GHC/Core/TyCo/Rep.hs @@ -255,12 +255,15 @@ about it! * FFunTy is the data constructor, meaning "full function type". * The function type constructor (->) has kind - (->) :: forall r1 r2. TYPE r1 -> TYPE r2 -> Type LiftedRep + (->) :: forall {r1} {r2}. TYPE r1 -> TYPE r2 -> Type LiftedRep mkTyConApp ensure that we convert a saturated application TyConApp (->) [r1,r2,t1,t2] into FunTy t1 t2 dropping the 'r1' and 'r2' arguments; they are easily recovered from 't1' and 't2'. +* For the time being its RuntimeRep quantifiers are left + inferred. This is to allow for it to evolve. + * The ft_af field says whether or not this is an invisible argument VisArg: t1 -> t2 Ordinary function type InvisArg: t1 => t2 t1 is guaranteed to be a predicate type, diff --git a/compiler/GHC/Core/Type.hs b/compiler/GHC/Core/Type.hs index fe6d721a05..fbbf43a2fa 100644 --- a/compiler/GHC/Core/Type.hs +++ b/compiler/GHC/Core/Type.hs @@ -1012,9 +1012,10 @@ Note [Representation of function types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Functions (e.g. Int -> Char) can be thought of as being applications -of funTyCon (known in Haskell surface syntax as (->)), +of funTyCon (known in Haskell surface syntax as (->)), (note that +`RuntimeRep' quantifiers are left inferred) - (->) :: forall (r1 :: RuntimeRep) (r2 :: RuntimeRep) + (->) :: forall {r1 :: RuntimeRep} {r2 :: RuntimeRep} (a :: TYPE r1) (b :: TYPE r2). a -> b -> Type |