diff options
author | Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> | 2021-07-28 15:20:44 +0200 |
---|---|---|
committer | Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> | 2021-08-02 19:19:38 +0200 |
commit | 808d0c1ecc6cdd247c5c39328540a3ae627aa309 (patch) | |
tree | 74f3428c9f1704865b64d2cd7809b3a3fcd3804e /compiler/GHC/Core/TyCon.hs | |
parent | 34e352173dd1fc3cd86c49380fda5a4eb5dd7aef (diff) | |
download | haskell-wip/funtycon-args.tar.gz |
Use a pattern synonym for arguments to FunTy (#18750)wip/funtycon-args
This makes it easier to add more arguments to FunTy in the future.
Not done in Unify.hs, because of perf problems #20165.
Diffstat (limited to 'compiler/GHC/Core/TyCon.hs')
-rw-r--r-- | compiler/GHC/Core/TyCon.hs | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/compiler/GHC/Core/TyCon.hs b/compiler/GHC/Core/TyCon.hs index 512ac4737c..e24b58fdd3 100644 --- a/compiler/GHC/Core/TyCon.hs +++ b/compiler/GHC/Core/TyCon.hs @@ -11,6 +11,8 @@ The @TyCon@ datatype -} +{-# LANGUAGE PatternSynonyms #-} + module GHC.Core.TyCon( -- * Main TyCon data types TyCon, @@ -30,6 +32,13 @@ module GHC.Core.TyCon( -- ** Field labels tyConFieldLabels, lookupTyConFieldLabel, + pattern FunTyConArgs, + funTyConMulArgNo, + funTyConArgRRArgNo, + funTyConResRRArgNo, + funTyConArgArgNo, + funTyConResArgNo, + -- ** Constructing TyCons mkAlgTyCon, mkClassTyCon, @@ -1705,6 +1714,24 @@ module mutual-recursion. And they aren't called from many places. So we compromise, and move their Kind calculation to the call site. -} +-- | This pattern synonym signifies arguments to the FUN type, +-- allowing easier grepping (#18750). +-- If it cannot be used in some place, you should leave a comment +-- mentioning FunTyConArgs. +-- The same construct is used for FunCos, see Note [Function coercions] +-- in GHC.Core.Coercion. +pattern FunTyConArgs :: a -> a -> a -> a -> a -> [a] +pattern FunTyConArgs mul r1 r2 arg res = [mul, r1, r2, arg, res] + +-- Integers denoting positions of arguments to FunTy. +funTyConMulArgNo, funTyConArgRRArgNo, funTyConResRRArgNo, funTyConArgArgNo, + funTyConResArgNo :: Int +funTyConMulArgNo = 0 +funTyConArgRRArgNo = 1 +funTyConResRRArgNo = 2 +funTyConArgArgNo = 3 +funTyConResArgNo = 4 + -- | Given the name of the function type constructor and it's kind, create the -- corresponding 'TyCon'. It is recommended to use 'GHC.Core.TyCo.Rep.funTyCon' if you want -- this functionality @@ -2516,7 +2543,7 @@ tyConRoles :: TyCon -> [Role] -- See also Note [TyCon Role signatures] tyConRoles tc = case tc of - { FunTyCon {} -> [Nominal, Nominal, Nominal, Representational, Representational] + { FunTyCon {} -> FunTyConArgs Nominal Nominal Nominal Representational Representational ; AlgTyCon { tcRoles = roles } -> roles ; SynonymTyCon { tcRoles = roles } -> roles ; FamilyTyCon {} -> const_role Nominal |