diff options
author | Richard Eisenberg <eir@cis.upenn.edu> | 2015-12-11 18:19:53 -0500 |
---|---|---|
committer | Richard Eisenberg <eir@cis.upenn.edu> | 2015-12-11 18:23:12 -0500 |
commit | 6746549772c5cc0ac66c0fce562f297f4d4b80a2 (patch) | |
tree | 96869fcfb5757651462511d64d99a3712f09e7fb /compiler/basicTypes/IdInfo.hs | |
parent | 6e56ac58a6905197412d58e32792a04a63b94d7e (diff) | |
download | haskell-6746549772c5cc0ac66c0fce562f297f4d4b80a2.tar.gz |
Add kind equalities to GHC.
This implements the ideas originally put forward in
"System FC with Explicit Kind Equality" (ICFP'13).
There are several noteworthy changes with this patch:
* We now have casts in types. These change the kind
of a type. See new constructor `CastTy`.
* All types and all constructors can be promoted.
This includes GADT constructors. GADT pattern matches
take place in type family equations. In Core,
types can now be applied to coercions via the
`CoercionTy` constructor.
* Coercions can now be heterogeneous, relating types
of different kinds. A coercion proving `t1 :: k1 ~ t2 :: k2`
proves both that `t1` and `t2` are the same and also that
`k1` and `k2` are the same.
* The `Coercion` type has been significantly enhanced.
The documentation in `docs/core-spec/core-spec.pdf` reflects
the new reality.
* The type of `*` is now `*`. No more `BOX`.
* Users can write explicit kind variables in their code,
anywhere they can write type variables. For backward compatibility,
automatic inference of kind-variable binding is still permitted.
* The new extension `TypeInType` turns on the new user-facing
features.
* Type families and synonyms are now promoted to kinds. This causes
trouble with parsing `*`, leading to the somewhat awkward new
`HsAppsTy` constructor for `HsType`. This is dispatched with in
the renamer, where the kind `*` can be told apart from a
type-level multiplication operator. Without `-XTypeInType` the
old behavior persists. With `-XTypeInType`, you need to import
`Data.Kind` to get `*`, also known as `Type`.
* The kind-checking algorithms in TcHsType have been significantly
rewritten to allow for enhanced kinds.
* The new features are still quite experimental and may be in flux.
* TODO: Several open tickets: #11195, #11196, #11197, #11198, #11203.
* TODO: Update user manual.
Tickets addressed: #9017, #9173, #7961, #10524, #8566, #11142.
Updates Haddock submodule.
Diffstat (limited to 'compiler/basicTypes/IdInfo.hs')
-rw-r--r-- | compiler/basicTypes/IdInfo.hs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/compiler/basicTypes/IdInfo.hs b/compiler/basicTypes/IdInfo.hs index 6f00df5f6f..450644d734 100644 --- a/compiler/basicTypes/IdInfo.hs +++ b/compiler/basicTypes/IdInfo.hs @@ -10,7 +10,7 @@ Haskell. [WDP 94/11]) module IdInfo ( -- * The IdDetails type - IdDetails(..), pprIdDetails, coVarDetails, + IdDetails(..), pprIdDetails, coVarDetails, isCoVarDetails, RecSelParent(..), -- * The IdInfo type @@ -135,20 +135,19 @@ data IdDetails -- implemented with a newtype, so it might be bad -- to be strict on this dictionary + | CoVarId -- ^ A coercion variable + -- The rest are distinguished only for debugging reasons -- e.g. to suppress them in -ddump-types -- Currently we don't persist these through interface file -- (see MkIface.toIfaceIdDetails), but we easily could if it mattered - | DefMethId -- ^ A default-method Id, either polymorphic or generic - | ReflectionId -- ^ A top-level Id to support runtime reflection -- e.g. $trModule, or $tcT | PatSynId -- ^ A top-level Id to support pattern synonyms; -- the builder or matcher for the patern synonym - data RecSelParent = RecSelData TyCon | RecSelPatSyn PatSyn deriving Eq -- Either `TyCon` or `PatSyn` depending -- on the origin of the record selector. @@ -160,10 +159,15 @@ instance Outputable RecSelParent where RecSelData ty_con -> ppr ty_con RecSelPatSyn ps -> ppr ps - - +-- | Just a synonym for 'CoVarId'. Written separately so it can be +-- exported in the hs-boot file. coVarDetails :: IdDetails -coVarDetails = VanillaId +coVarDetails = CoVarId + +-- | Check if an 'IdDetails' says 'CoVarId'. +isCoVarDetails :: IdDetails -> Bool +isCoVarDetails CoVarId = True +isCoVarDetails _ = False instance Outputable IdDetails where ppr = pprIdDetails @@ -173,7 +177,6 @@ pprIdDetails VanillaId = empty pprIdDetails other = brackets (pp other) where pp VanillaId = panic "pprIdDetails" - pp DefMethId = ptext (sLit "DefMethId") pp ReflectionId = ptext (sLit "ReflectionId") pp PatSynId = ptext (sLit "PatSynId") pp (DataConWorkId _) = ptext (sLit "DataCon") @@ -186,6 +189,7 @@ pprIdDetails other = brackets (pp other) pp (RecSelId { sel_naughty = is_naughty }) = brackets $ ptext (sLit "RecSel") <> ppWhen is_naughty (ptext (sLit "(naughty)")) + pp CoVarId = ptext (sLit "CoVarId") {- ************************************************************************ |