[Git][ghc/ghc][master] Implement the -XUnliftedNewtypes extension.

Marge Bot gitlab at gitlab.haskell.org
Fri Jun 14 14:48:17 UTC 2019



 Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
effdd948 by Andrew Martin at 2019-06-14T14:48:13Z
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 at richarde.dev>

- - - - -


30 changed files:

- compiler/basicTypes/Id.hs
- compiler/basicTypes/MkId.hs
- compiler/codeGen/StgCmmForeign.hs
- compiler/deSugar/DsExpr.hs
- compiler/hsSyn/HsTypes.hs
- compiler/main/DynFlags.hs
- compiler/main/TidyPgm.hs
- compiler/prelude/TysPrim.hs
- compiler/prelude/primops.txt.pp
- compiler/rename/RnSource.hs
- compiler/typecheck/TcErrors.hs
- compiler/typecheck/TcEvidence.hs
- compiler/typecheck/TcHsType.hs
- compiler/typecheck/TcInstDcls.hs
- compiler/typecheck/TcMType.hs
- compiler/typecheck/TcSimplify.hs
- compiler/typecheck/TcTyClsDecls.hs
- compiler/typecheck/TcTypeable.hs
- compiler/types/Coercion.hs
- compiler/types/Type.hs
- docs/users_guide/8.10.1-notes.rst
- docs/users_guide/glasgow_exts.rst
- libraries/base/Control/Category.hs
- libraries/base/Data/Coerce.hs
- libraries/base/Data/Type/Coercion.hs
- libraries/base/GHC/Base.hs
- libraries/base/changelog.md
- libraries/ghc-boot-th/GHC/LanguageExtensions/Type.hs
- libraries/ghc-prim/GHC/Types.hs
- testsuite/tests/codeGen/should_fail/T13233.stderr


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/effdd948056923f3bc03688c24d7e0339d6272f5

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/effdd948056923f3bc03688c24d7e0339d6272f5
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190614/98795fca/attachment.html>


More information about the ghc-commits mailing list