Commit 05d233e8 authored by Simon Peyton Jones's avatar Simon Peyton Jones

Move InId/OutId to CoreSyn

It turned out that many different modules defined the same type
synonyms (InId, OutId, InType, OutType, etc) for the same purpose.

This patch is refactoring only: it moves all those definitions to
CoreSyn.
parent 0a18231b
......@@ -601,24 +601,12 @@ the desugarer.
************************************************************************
-}
type InType = Type
type InCoercion = Coercion
type InVar = Var
type InTyVar = Var
type InCoVar = Var
type OutType = Type -- Substitution has been applied to this,
-- but has not been linted yet
type OutKind = Kind
-- For OutType, OutKind, the substitution has been applied,
-- but has not been linted yet
type LintedType = Type -- Substitution applied, and type is linted
type LintedKind = Kind
type OutCoercion = Coercion
type OutVar = Var
type OutTyVar = TyVar
type OutCoVar = Var
lintCoreExpr :: CoreExpr -> LintM OutType
-- The returned type has the substitution from the monad
-- already applied to it:
......
......@@ -81,6 +81,7 @@ import Data.List
import TysWiredIn
{-
************************************************************************
* *
......@@ -907,14 +908,6 @@ simpleOptPgm dflags this_mod binds rules vects
(subst', Nothing) -> (subst', binds')
(subst', Just bind') -> (subst', bind':binds')
----------------------
type InVar = Var
type OutVar = Var
type InId = Id
type OutId = Id
type InExpr = CoreExpr
type OutExpr = CoreExpr
-- In these functions the substitution maps InVar -> OutExpr
----------------------
......
......@@ -13,6 +13,12 @@ module CoreSyn (
CoreProgram, CoreExpr, CoreAlt, CoreBind, CoreArg, CoreBndr,
TaggedExpr, TaggedAlt, TaggedBind, TaggedArg, TaggedBndr(..), deTagExpr,
-- * In/Out type synonyms
InId, InBind, InExpr, InAlt, InArg, InType, InKind,
InBndr, InVar, InCoercion, InTyVar, InCoVar,
OutId, OutBind, OutExpr, OutAlt, OutArg, OutType, OutKind,
OutBndr, OutVar, OutCoercion, OutTyVar, OutCoVar,
-- ** 'Expr' construction
mkLets, mkLams,
mkApps, mkTyApps, mkCoApps, mkVarApps,
......@@ -40,6 +46,7 @@ module CoreSyn (
isValArg, isTypeArg, isTyCoArg, valArgCount, valBndrCount,
isRuntimeArg, isRuntimeVar,
-- * Tick-related functions
tickishCounts, tickishScoped, tickishScopesLike, tickishFloatable,
tickishCanSplit, mkNoCount, mkNoScope,
tickishIsCode, tickishPlace,
......@@ -393,7 +400,7 @@ The levity-polymorphism invariants are these:
A type (t::TYPE r) is "levity polymorphic" if 'r' has any free variables.
For example
(\(r::RuntimeRep). \(a::TYPE r). \(x::a). e
\(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]
......@@ -460,6 +467,44 @@ this exhaustive list can be empty!
************************************************************************
* *
In/Out type synonyms
* *
********************************************************************* -}
{- Many passes apply a substitution, and it's very handy to have type
synonyms to remind us whether or not the subsitution has been applied -}
-- Pre-cloning or substitution
type InBndr = CoreBndr
type InVar = Var
type InTyVar = TyVar
type InCoVar = CoVar
type InId = Id
type InType = Type
type InKind = Kind
type InBind = CoreBind
type InExpr = CoreExpr
type InAlt = CoreAlt
type InArg = CoreArg
type InCoercion = Coercion
-- Post-cloning or substitution
type OutBndr = CoreBndr
type OutVar = Var
type OutId = Id
type OutTyVar = TyVar
type OutCoVar = CoVar
type OutType = Type
type OutKind = Kind
type OutCoercion = Coercion
type OutBind = CoreBind
type OutExpr = CoreExpr
type OutAlt = CoreAlt
type OutArg = CoreArg
{- *********************************************************************
* *
Ticks
* *
......@@ -1091,7 +1136,7 @@ data UnfoldingGuidance
-- Used (a) for small *and* cheap unfoldings
-- (b) for INLINE functions
-- See Note [INLINE for small functions] in CoreUnfold
ug_arity :: Arity, -- Number of value arguments expected
ug_arity :: Arity, -- Number of value arguments expected
ug_unsat_ok :: Bool, -- True <=> ok to inline even if unsaturated
ug_boring_ok :: Bool -- True <=> ok to inline even if the context is boring
......
......@@ -17,7 +17,7 @@ import Id ( Id, idType, idUnfolding, idInlineActivation
import CoreUtils ( mkAltExpr
, exprIsTrivial, exprOkForSpeculation
, stripTicksE, stripTicksT, mkTicks )
import Type ( Type, tyConAppArgs, isUnliftedType )
import Type ( tyConAppArgs, isUnliftedType )
import CoreSyn
import Outputable
import BasicTypes ( isAlwaysActive )
......@@ -368,15 +368,6 @@ cseCase env scrut bndr ty alts
************************************************************************
-}
type InExpr = CoreExpr -- Pre-cloning
type InId = Id
type InAlt = CoreAlt
type InType = Type
type OutExpr = CoreExpr -- Post-cloning
type OutId = Id
type OutType = Type
data CSEnv
= CS { cs_subst :: Subst -- Maps InBndrs to OutExprs
-- The substitution variables to
......
......@@ -935,11 +935,6 @@ countFreeIds = nonDetFoldUDFM add 0
************************************************************************
-}
type InVar = Var -- Pre cloning
type InId = Id -- Pre cloning
type OutVar = Var -- Post cloning
type OutId = Id -- Post cloning
data LevelEnv
= LE { le_switches :: FloatOutSwitches
, le_ctxt_lvl :: Level -- The current level
......
......@@ -7,11 +7,6 @@
{-# LANGUAGE CPP #-}
module SimplEnv (
-- * Basic types
InId, InBind, InExpr, InAlt, InArg, InType, InBndr, InVar,
OutId, OutTyVar, OutBind, OutExpr, OutAlt, OutArg, OutType, OutBndr, OutVar,
InCoercion, OutCoercion,
-- * The simplifier mode
setMode, getMode, updMode,
......@@ -62,35 +57,6 @@ import Util
import Data.List
{-
************************************************************************
* *
\subsection[Simplify-types]{Type declarations}
* *
************************************************************************
-}
type InBndr = CoreBndr
type InVar = Var -- Not yet cloned
type InId = Id -- Not yet cloned
type InType = Type -- Ditto
type InBind = CoreBind
type InExpr = CoreExpr
type InAlt = CoreAlt
type InArg = CoreArg
type InCoercion = Coercion
type OutBndr = CoreBndr
type OutVar = Var -- Cloned
type OutId = Id -- Cloned
type OutTyVar = TyVar -- Cloned
type OutType = Type -- Cloned
type OutCoercion = Coercion
type OutBind = CoreBind
type OutExpr = CoreExpr
type OutAlt = CoreAlt
type OutArg = CoreArg
{-
************************************************************************
* *
......
......@@ -265,8 +265,6 @@ extendRho rho x (UnaryVal val)
--------------------------------------------------------------------------------
type OutStgExpr = StgExpr
type InId = Id
type OutId = Id
type InStgAlt = StgAlt
type InStgArg = StgArg
type OutStgArg = StgArg
......
......@@ -787,15 +787,6 @@ data ScEnv = SCE { sc_dflags :: DynFlags,
sc_annotations :: UniqFM SpecConstrAnnotation
}
---------------------
-- As we go, we apply a substitution (sc_subst) to the current term
type InExpr = CoreExpr -- _Before_ applying the subst
type InVar = Var
type OutExpr = CoreExpr -- _After_ applying the subst
type OutId = Id
type OutVar = Var
---------------------
type HowBoundEnv = VarEnv HowBound -- Domain is OutVars
......
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