Implement the -XUnliftedNewtypes extension.
GHC Proposal: 0013-unlifted-newtypes.rst Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/98 Issues: #15219, #1311, #13595, #15883 Implementation Details: Note [Implementation of UnliftedNewtypes] Note [Unifying data family kinds] Note [Compulsory newtype unfolding] This patch introduces the -XUnliftedNewtypes extension. When this extension is enabled, GHC drops the restriction that the field in a newtype must be of kind (TYPE 'LiftedRep). This allows types like Int# and ByteArray# to be used in a newtype. Additionally, coerce is made levity-polymorphic so that it can be used with newtypes over unlifted types. The bulk of the changes are in TcTyClsDecls.hs. With -XUnliftedNewtypes, getInitialKind is more liberal, introducing a unification variable to return the kind (TYPE r0) rather than just returning (TYPE 'LiftedRep). When kind-checking a data constructor with kcConDecl, we attempt to unify the kind of a newtype with the kind of its field's type. When typechecking a data declaration with tcTyClDecl, we again perform a unification. See the implementation note for more on this. Co-authored-by:Richard Eisenberg <rae@richarde.dev>
Showing
- compiler/basicTypes/Id.hs 1 addition, 1 deletioncompiler/basicTypes/Id.hs
- compiler/basicTypes/MkId.hs 47 additions, 14 deletionscompiler/basicTypes/MkId.hs
- compiler/codeGen/StgCmmForeign.hs 4 additions, 1 deletioncompiler/codeGen/StgCmmForeign.hs
- compiler/deSugar/DsExpr.hs 9 additions, 5 deletionscompiler/deSugar/DsExpr.hs
- compiler/hsSyn/HsTypes.hs 9 additions, 0 deletionscompiler/hsSyn/HsTypes.hs
- compiler/main/DynFlags.hs 1 addition, 0 deletionscompiler/main/DynFlags.hs
- compiler/main/TidyPgm.hs 3 additions, 1 deletioncompiler/main/TidyPgm.hs
- compiler/prelude/TysPrim.hs 22 additions, 6 deletionscompiler/prelude/TysPrim.hs
- compiler/prelude/primops.txt.pp 5 additions, 0 deletionscompiler/prelude/primops.txt.pp
- compiler/rename/RnSource.hs 47 additions, 7 deletionscompiler/rename/RnSource.hs
- compiler/typecheck/TcErrors.hs 13 additions, 9 deletionscompiler/typecheck/TcErrors.hs
- compiler/typecheck/TcEvidence.hs 8 additions, 1 deletioncompiler/typecheck/TcEvidence.hs
- compiler/typecheck/TcHsType.hs 0 additions, 2 deletionscompiler/typecheck/TcHsType.hs
- compiler/typecheck/TcInstDcls.hs 77 additions, 22 deletionscompiler/typecheck/TcInstDcls.hs
- compiler/typecheck/TcMType.hs 1 addition, 0 deletionscompiler/typecheck/TcMType.hs
- compiler/typecheck/TcSimplify.hs 53 additions, 7 deletionscompiler/typecheck/TcSimplify.hs
- compiler/typecheck/TcTyClsDecls.hs 268 additions, 69 deletionscompiler/typecheck/TcTyClsDecls.hs
- compiler/typecheck/TcTypeable.hs 6 additions, 4 deletionscompiler/typecheck/TcTypeable.hs
- compiler/types/Coercion.hs 6 additions, 1 deletioncompiler/types/Coercion.hs
- compiler/types/Type.hs 28 additions, 0 deletionscompiler/types/Type.hs
Loading
Please register or sign in to comment