summaryrefslogtreecommitdiff
path: root/compiler/GHC/Hs/Utils.hs
diff options
context:
space:
mode:
authorGert-Jan Bottu <gertjan.bottu@kuleuven.be>2020-03-23 09:36:28 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-05-21 12:11:31 -0400
commita9311cd53d33439e8fe79967ba5fb85bcd114fec (patch)
tree2254ef735a24f9de8d192203a3c6f4871a8b6ae9 /compiler/GHC/Hs/Utils.hs
parent55f0e783d234af103cf4e1d51cd31c99961c5abe (diff)
downloadhaskell-a9311cd53d33439e8fe79967ba5fb85bcd114fec.tar.gz
Explicit Specificity
Implementation for Ticket #16393. Explicit specificity allows users to manually create inferred type variables, by marking them with braces. This way, the user determines which variables can be instantiated through visible type application. The additional syntax is included in the parser, allowing users to write braces in type variable binders (type signatures, data constructors etc). This information is passed along through the renamer and verified in the type checker. The AST for type variable binders, data constructors, pattern synonyms, partial signatures and Template Haskell has been updated to include the specificity of type variables. Minor notes: - Bumps haddock submodule - Disables pattern match checking in GHC.Iface.Type with GHC 8.8
Diffstat (limited to 'compiler/GHC/Hs/Utils.hs')
-rw-r--r--compiler/GHC/Hs/Utils.hs19
1 files changed, 14 insertions, 5 deletions
diff --git a/compiler/GHC/Hs/Utils.hs b/compiler/GHC/Hs/Utils.hs
index 6e89b6844a..6301927b26 100644
--- a/compiler/GHC/Hs/Utils.hs
+++ b/compiler/GHC/Hs/Utils.hs
@@ -736,14 +736,23 @@ typeToLHsType ty
foldl' (\f (arg, flag) ->
let arg' = go arg in
case flag of
- Inferred -> f
- Specified -> f `nlHsAppKindTy` arg'
+ -- See Note [Explicit Case Statement for Specificity]
+ Invisible spec -> case spec of
+ InferredSpec -> f
+ SpecifiedSpec -> f `nlHsAppKindTy` arg'
Required -> f `nlHsAppTy` arg')
head (zip args arg_flags)
- go_tv :: TyVar -> LHsTyVarBndr GhcPs
- go_tv tv = noLoc $ KindedTyVar noExtField (noLoc (getRdrName tv))
- (go (tyVarKind tv))
+ argf_to_spec :: ArgFlag -> Specificity
+ argf_to_spec Required = SpecifiedSpec
+ -- see Note [Specificity in HsForAllTy] in GHC.Hs.Types
+ argf_to_spec (Invisible s) = s
+
+ go_tv :: TyVarBinder -> LHsTyVarBndr Specificity GhcPs
+ go_tv (Bndr tv argf) = noLoc $ KindedTyVar noExtField
+ (argf_to_spec argf)
+ (noLoc (getRdrName tv))
+ (go (tyVarKind tv))
{-
Note [Kind signatures in typeToLHsType]