Commit 03766cdb authored by Simon Peyton Jones's avatar Simon Peyton Jones

Rename RuntimeRepPolymorphism to LevityPolymorphism

Richard and I decided to make this change in our paper, and I'm
just propagating it to GHC
parent be8a47f5
...@@ -1030,7 +1030,7 @@ lintAndScopeId id linterF ...@@ -1030,7 +1030,7 @@ lintAndScopeId id linterF
(text "Non-local Id binder" <+> ppr id) (text "Non-local Id binder" <+> ppr id)
-- See Note [Checking for global Ids] -- See Note [Checking for global Ids]
; (ty, k) <- lintInTy (idType id) ; (ty, k) <- lintInTy (idType id)
; lintL (not (isRuntimeRepPolymorphic k)) ; lintL (not (isLevityPolymorphic k))
(text "RuntimeRep-polymorphic binder:" <+> (text "RuntimeRep-polymorphic binder:" <+>
(ppr id <+> dcolon <+> parens (ppr ty <+> dcolon <+> ppr k))) (ppr id <+> dcolon <+> parens (ppr ty <+> dcolon <+> ppr k)))
; let id' = setIdType id ty ; let id' = setIdType id ty
......
...@@ -169,10 +169,11 @@ These data types are the heart of the compiler ...@@ -169,10 +169,11 @@ These data types are the heart of the compiler
-- * Primitive literals -- * Primitive literals
-- --
-- * Applications: note that the argument may be a 'Type'. -- * Applications: note that the argument may be a 'Type'.
-- -- See Note [CoreSyn let/app invariant]
-- See "CoreSyn#let_app_invariant" for another invariant -- See Note [Levity polymorphism invariants]
-- --
-- * Lambda abstraction -- * Lambda abstraction
-- See Note [Levity polymorphism invariants]
-- --
-- * Recursive and non recursive @let@s. Operationally -- * Recursive and non recursive @let@s. Operationally
-- this corresponds to allocating a thunk for the things -- this corresponds to allocating a thunk for the things
...@@ -186,6 +187,7 @@ These data types are the heart of the compiler ...@@ -186,6 +187,7 @@ These data types are the heart of the compiler
-- the meaning of /lifted/ vs. /unlifted/). -- the meaning of /lifted/ vs. /unlifted/).
-- --
-- See Note [CoreSyn let/app invariant] -- See Note [CoreSyn let/app invariant]
-- See Note [Levity polymorphism invariants]
-- --
-- #type_let# -- #type_let#
-- We allow a /non-recursive/ let to bind a type variable, thus: -- We allow a /non-recursive/ let to bind a type variable, thus:
...@@ -199,7 +201,7 @@ These data types are the heart of the compiler ...@@ -199,7 +201,7 @@ These data types are the heart of the compiler
-- in a Let expression, rather than at top level. We may want to revist -- in a Let expression, rather than at top level. We may want to revist
-- this choice. -- this choice.
-- --
-- * Case split. Operationally this corresponds to evaluating -- * Case expression. Operationally this corresponds to evaluating
-- the scrutinee (expression examined) to weak head normal form -- the scrutinee (expression examined) to weak head normal form
-- and then examining at most one level of resulting constructor (i.e. you -- and then examining at most one level of resulting constructor (i.e. you
-- cannot do nested pattern matching directly with this). -- cannot do nested pattern matching directly with this).
...@@ -381,6 +383,19 @@ Note [CoreSyn case invariants] ...@@ -381,6 +383,19 @@ Note [CoreSyn case invariants]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
See #case_invariants# See #case_invariants#
Note [Levity polymorphism invariants]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The levity-polymorphism invariants are these:
* The type of a term-binder must not be levity-polymorphic
* The type of the argument of an App must not be levity-polymorphic.
A type (t::TYPE r) is "levity polymorphic" if 'r' has any free variables.
For example
(\(r::RuntimeRep). \(a::TYPE r). \(x::a). e
is illegal because x's type has kind (TYPE r), which has 'r' free.
Note [CoreSyn let goal] Note [CoreSyn let goal]
~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~
* The simplifier tries to ensure that if the RHS of a let is a constructor * The simplifier tries to ensure that if the RHS of a let is a constructor
......
...@@ -142,7 +142,7 @@ module TcType ( ...@@ -142,7 +142,7 @@ module TcType (
mkClassPred, mkClassPred,
isDictLikeTy, isDictLikeTy,
tcSplitDFunTy, tcSplitDFunHead, tcSplitMethodTy, tcSplitDFunTy, tcSplitDFunHead, tcSplitMethodTy,
isRuntimeRepVar, isRuntimeRepPolymorphic, isRuntimeRepVar, isLevityPolymorphic,
isVisibleBinder, isInvisibleBinder, isVisibleBinder, isInvisibleBinder,
-- Type substitutions -- Type substitutions
......
...@@ -14,7 +14,7 @@ module Kind ( ...@@ -14,7 +14,7 @@ module Kind (
classifiesTypeWithValues, classifiesTypeWithValues,
isStarKind, isStarKindSynonymTyCon, isStarKind, isStarKindSynonymTyCon,
isRuntimeRepPolymorphic isLevityPolymorphic
) where ) where
#include "HsVersions.h" #include "HsVersions.h"
...@@ -77,10 +77,10 @@ returnsTyCon _ _ = False ...@@ -77,10 +77,10 @@ returnsTyCon _ _ = False
returnsConstraintKind :: Kind -> Bool returnsConstraintKind :: Kind -> Bool
returnsConstraintKind = returnsTyCon constraintKindTyConKey returnsConstraintKind = returnsTyCon constraintKindTyConKey
-- | Tests whether the given type (which should look like "TYPE ...") has any -- | Tests whether the given kind (which should look like "TYPE ...")
-- free variables -- has any free variables
isRuntimeRepPolymorphic :: Kind -> Bool isLevityPolymorphic :: Kind -> Bool
isRuntimeRepPolymorphic k isLevityPolymorphic k
= not $ isEmptyVarSet $ tyCoVarsOfType k = not $ isEmptyVarSet $ tyCoVarsOfType k
-------------------------------------------- --------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment