Update levity polymorphism
authorRichard Eisenberg <rae@cs.brynmawr.edu>
Thu, 15 Dec 2016 02:37:43 +0000 (21:37 -0500)
committerRichard Eisenberg <rae@cs.brynmawr.edu>
Thu, 19 Jan 2017 15:31:52 +0000 (10:31 -0500)
commite7985ed23ddc68b6a2e4af753578dc1d9e8ab4c9
treeba8c4016e218710f8165db92d4b4c10e5559245a
parent38374caa9d6e1373d1b9d335d0f99f3664931fd9
Update levity polymorphism

This commit implements the proposal in
https://github.com/ghc-proposals/ghc-proposals/pull/29 and
https://github.com/ghc-proposals/ghc-proposals/pull/35.

Here are some of the pieces of that proposal:

* Some of RuntimeRep's constructors have been shortened.

* TupleRep and SumRep are now parameterized over a list of RuntimeReps.
* This
means that two types with the same kind surely have the same
representation.
Previously, all unboxed tuples had the same kind, and thus the fact
above was
false.

* RepType.typePrimRep and friends now return a *list* of PrimReps. These
functions can now work successfully on unboxed tuples. This change is
necessary because we allow abstraction over unboxed tuple types and so
cannot
always handle unboxed tuples specially as we did before.

* We sometimes have to create an Id from a PrimRep. I thus split PtrRep
* into
LiftedRep and UnliftedRep, so that the created Ids have the right
strictness.

* The RepType.RepType type was removed, as it didn't seem to help with
* much.

* The RepType.repType function is also removed, in favor of typePrimRep.

* I have waffled a good deal on whether or not to keep VoidRep in
TyCon.PrimRep. In the end, I decided to keep it there. PrimRep is *not*
represented in RuntimeRep, and typePrimRep will never return a list
including
VoidRep. But it's handy to have in, e.g., ByteCodeGen and friends. I can
imagine another design choice where we have a PrimRepV type that is
PrimRep
with an extra constructor. That seemed to be a heavier design, though,
and I'm
not sure what the benefit would be.

* The last, unused vestiges of # (unliftedTypeKind) have been removed.

* There were several pretty-printing bugs that this change exposed;
* these are fixed.

* We previously checked for levity polymorphism in the types of binders.
* But we
also must exclude levity polymorphism in function arguments. This is
hard to check
for, requiring a good deal of care in the desugarer. See Note [Levity
polymorphism
checking] in DsMonad.

* In order to efficiently check for levity polymorphism in functions, it
* was necessary
to add a new bit of IdInfo. See Note [Levity info] in IdInfo.

* It is now safe for unlifted types to be unsaturated in Core. Core Lint
* is updated
accordingly.

* We can only know strictness after zonking, so several checks around
* strictness
in the type-checker (checkStrictBinds, the check for unlifted variables
under a ~
pattern) have been moved to the desugarer.

* Along the way, I improved the treatment of unlifted vs. banged
* bindings. See
Note [Strict binds checks] in DsBinds and #13075.

* Now that we print type-checked source, we must be careful to print
* ConLikes correctly.
This is facilitated by a new HsConLikeOut constructor to HsExpr.
Particularly troublesome
are unlifted pattern synonyms that get an extra void# argument.

* Includes a submodule update for haddock, getting rid of #.

* New testcases:
  typecheck/should_fail/StrictBinds
  typecheck/should_fail/T12973
  typecheck/should_run/StrictPats
  typecheck/should_run/T12809
  typecheck/should_fail/T13105
  patsyn/should_fail/UnliftedPSBind
  typecheck/should_fail/LevPolyBounded
  typecheck/should_compile/T12987
  typecheck/should_compile/T11736

* Fixed tickets:
  #12809
  #12973
  #11736
  #13075
  #12987

* This also adds a test case for #13105. This test case is
* "compile_fail" and
succeeds, because I want the testsuite to monitor the error message.
When #13105 is fixed, the test case will compile cleanly.
163 files changed:
compiler/basicTypes/BasicTypes.hs
compiler/basicTypes/Id.hs
compiler/basicTypes/IdInfo.hs
compiler/basicTypes/MkId.hs
compiler/cmm/CmmUtils.hs
compiler/codeGen/StgCmm.hs
compiler/codeGen/StgCmmArgRep.hs
compiler/codeGen/StgCmmClosure.hs
compiler/codeGen/StgCmmEnv.hs
compiler/codeGen/StgCmmExpr.hs
compiler/codeGen/StgCmmForeign.hs
compiler/codeGen/StgCmmUtils.hs
compiler/coreSyn/CoreArity.hs
compiler/coreSyn/CoreLint.hs
compiler/coreSyn/CoreSubst.hs
compiler/coreSyn/CoreSyn.hs
compiler/coreSyn/CoreUtils.hs
compiler/coreSyn/MkCore.hs
compiler/coreSyn/PprCore.hs
compiler/deSugar/Coverage.hs
compiler/deSugar/DsArrows.hs
compiler/deSugar/DsBinds.hs
compiler/deSugar/DsCCall.hs
compiler/deSugar/DsExpr.hs
compiler/deSugar/DsExpr.hs-boot
compiler/deSugar/DsForeign.hs
compiler/deSugar/DsGRHSs.hs
compiler/deSugar/DsListComp.hs
compiler/deSugar/DsMonad.hs
compiler/deSugar/DsUtils.hs
compiler/deSugar/Match.hs
compiler/deSugar/MatchCon.hs
compiler/deSugar/PmExpr.hs
compiler/ghci/ByteCodeGen.hs
compiler/ghci/ByteCodeItbls.hs
compiler/ghci/Debugger.hs
compiler/ghci/GHCi.hsc
compiler/ghci/RtClosureInspect.hs
compiler/hsSyn/HsBinds.hs
compiler/hsSyn/HsExpr.hs
compiler/hsSyn/HsPat.hs
compiler/hsSyn/HsUtils.hs
compiler/iface/IfaceSyn.hs
compiler/iface/IfaceType.hs
compiler/iface/TcIface.hs
compiler/iface/ToIface.hs
compiler/main/DynFlags.hs
compiler/main/HscTypes.hs
compiler/main/InteractiveEval.hs
compiler/prelude/PrelNames.hs
compiler/prelude/PrimOp.hs
compiler/prelude/TysPrim.hs
compiler/prelude/TysWiredIn.hs
compiler/prelude/TysWiredIn.hs-boot
compiler/simplCore/SetLevels.hs
compiler/simplCore/SimplEnv.hs
compiler/simplCore/SimplUtils.hs
compiler/simplCore/Simplify.hs
compiler/simplStg/RepType.hs
compiler/simplStg/UnariseStg.hs
compiler/stgSyn/CoreToStg.hs
compiler/stgSyn/StgLint.hs
compiler/stgSyn/StgSyn.hs
compiler/typecheck/TcBinds.hs
compiler/typecheck/TcCanonical.hs
compiler/typecheck/TcEnv.hs
compiler/typecheck/TcErrors.hs
compiler/typecheck/TcEvidence.hs
compiler/typecheck/TcExpr.hs
compiler/typecheck/TcGenFunctor.hs
compiler/typecheck/TcHsSyn.hs
compiler/typecheck/TcHsType.hs
compiler/typecheck/TcInstDcls.hs
compiler/typecheck/TcMType.hs
compiler/typecheck/TcPat.hs
compiler/typecheck/TcPatSyn.hs
compiler/typecheck/TcRnTypes.hs
compiler/typecheck/TcSigs.hs
compiler/typecheck/TcSimplify.hs
compiler/typecheck/TcTyClsDecls.hs
compiler/typecheck/TcType.hs
compiler/typecheck/TcTypeable.hs
compiler/typecheck/TcUnify.hs
compiler/types/FamInstEnv.hs
compiler/types/Kind.hs
compiler/types/TyCoRep.hs
compiler/types/TyCon.hs
compiler/types/Type.hs
compiler/utils/Bag.hs
compiler/utils/Outputable.hs
docs/users_guide/glasgow_exts.rst
docs/users_guide/using-warnings.rst
docs/users_guide/using.rst
libraries/base/Data/Typeable/Internal.hs
libraries/base/Unsafe/Coerce.hs
libraries/base/tests/T11334a.hs
libraries/base/tests/T11334a.stdout
libraries/ghc-prim/GHC/Types.hs
libraries/integer-gmp/src/GHC/Integer/Logarithms.hs
libraries/integer-gmp/src/GHC/Integer/Type.hs
testsuite/tests/deSugar/should_compile/T10662.stderr
testsuite/tests/dependent/should_compile/RaeJobTalk.hs
testsuite/tests/dependent/should_fail/T11473.stderr
testsuite/tests/deriving/should_fail/T12512.hs
testsuite/tests/deriving/should_fail/T12512.stderr
testsuite/tests/ghci/scripts/GhciKinds.stdout
testsuite/tests/ghci/scripts/T9140.stdout
testsuite/tests/patsyn/should_fail/UnliftedPSBind.hs [new file with mode: 0644]
testsuite/tests/patsyn/should_fail/UnliftedPSBind.stderr [new file with mode: 0644]
testsuite/tests/patsyn/should_fail/all.T
testsuite/tests/patsyn/should_fail/unboxed-bind.hs
testsuite/tests/patsyn/should_fail/unboxed-bind.stderr
testsuite/tests/quasiquotation/T7918.stdout
testsuite/tests/simplCore/should_compile/T9400.stderr
testsuite/tests/simplCore/should_compile/spec-inline.stderr
testsuite/tests/th/T12403.stdout
testsuite/tests/th/T12478_1.stdout
testsuite/tests/th/T5358.stderr
testsuite/tests/th/T5976.stderr
testsuite/tests/th/T8987.stderr
testsuite/tests/typecheck/should_compile/T11723.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/T11736.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/T12987.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/all.T
testsuite/tests/typecheck/should_fail/BadUnboxedTuple.hs [deleted file]
testsuite/tests/typecheck/should_fail/BadUnboxedTuple.stderr [deleted file]
testsuite/tests/typecheck/should_fail/LevPolyBounded.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/LevPolyBounded.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/StrictBinds.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/StrictBinds.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T11723.hs [deleted file]
testsuite/tests/typecheck/should_fail/T11723.stderr [deleted file]
testsuite/tests/typecheck/should_fail/T11724.stderr
testsuite/tests/typecheck/should_fail/T12973.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T12973.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T13105.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T13105.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T2806.hs
testsuite/tests/typecheck/should_fail/T2806.stderr
testsuite/tests/typecheck/should_fail/T6078.stderr
testsuite/tests/typecheck/should_fail/all.T
testsuite/tests/typecheck/should_fail/tcfail203.hs
testsuite/tests/typecheck/should_fail/tcfail203.stderr
testsuite/tests/typecheck/should_fail/tcfail203a.stderr
testsuite/tests/typecheck/should_run/EtaExpandLevPoly.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_run/EtaExpandLevPoly.stdout [new file with mode: 0644]
testsuite/tests/typecheck/should_run/KindInvariant.stderr
testsuite/tests/typecheck/should_run/StrictPats.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_run/StrictPats.stdout [new file with mode: 0644]
testsuite/tests/typecheck/should_run/T12809.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_run/T12809.stdout [new file with mode: 0644]
testsuite/tests/typecheck/should_run/TypeOf.hs
testsuite/tests/typecheck/should_run/TypeOf.stdout
testsuite/tests/typecheck/should_run/TypeRep.hs
testsuite/tests/typecheck/should_run/TypeRep.stdout
testsuite/tests/typecheck/should_run/all.T
testsuite/tests/unboxedsums/T12711.stdout
testsuite/tests/unboxedsums/UbxSumLevPoly.hs [new file with mode: 0644]
testsuite/tests/unboxedsums/all.T
testsuite/tests/unboxedsums/sum_rr.hs
testsuite/tests/unboxedsums/sum_rr.stderr [deleted file]
testsuite/tests/unboxedsums/unboxedsums_unit_tests.hs
utils/haddock