Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
18a346a4
Commit
18a346a4
authored
Mar 02, 2020
by
Sylvain Henry
Committed by
Marge Bot
Mar 16, 2020
Browse files
Modules: Core (
#13009
)
Update submodule: haddock
parent
818b3c38
Pipeline
#16791
passed with stages
in 393 minutes and 45 seconds
Changes
224
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
compiler/GHC.hs
View file @
18a346a4
...
...
@@ -311,27 +311,28 @@ import GHC.Driver.Monad
import
TcRnMonad
(
finalSafeMode
,
fixSafeInstances
,
initIfaceTcRn
)
import
GHC.Iface.Load
(
loadSysInterface
)
import
TcRnTypes
import
Predicate
import
GHC.Core.
Predicate
import
GHC.Driver.Packages
import
NameSet
import
RdrName
import
GHC.Hs
import
Type
hiding
(
typeKind
)
import
GHC.Core.
Type
hiding
(
typeKind
)
import
TcType
import
Id
import
TysPrim
(
alphaTyVars
)
import
TyCon
import
TyCoPpr
(
pprForAll
)
import
Class
import
DataCon
import
GHC.Core.TyCon
import
GHC.Core.TyCo.Ppr
(
pprForAll
)
import
GHC.Core.Class
import
GHC.Core.DataCon
import
GHC.Core.FVs
(
orphNamesOfFamInst
)
import
GHC.Core.FamInstEnv
(
FamInst
,
famInstEnvElts
)
import
GHC.Core.InstEnv
import
Name
hiding
(
varName
)
import
Avail
import
InstEnv
import
FamInstEnv
(
FamInst
)
import
SrcLoc
import
GHC.Core
import
GHC.Iface.Tidy
import
GHC.Driver.Phases
(
Phase
(
..
),
isHaskellSrcFilename
)
import
GHC.Driver.Phases
(
Phase
(
..
),
isHaskellSrcFilename
)
import
GHC.Driver.Finder
import
GHC.Driver.Types
import
GHC.Driver.CmdLine
...
...
@@ -356,8 +357,6 @@ import Lexer
import
ApiAnnotation
import
qualified
GHC.LanguageExtensions
as
LangExt
import
NameEnv
import
GHC.Core.FVs
(
orphNamesOfFamInst
)
import
FamInstEnv
(
famInstEnvElts
)
import
TcRnDriver
import
Inst
import
FamInst
...
...
compiler/GHC/ByteCode/Asm.hs
View file @
18a346a4
...
...
@@ -27,7 +27,7 @@ import GHC.Driver.Types
import
Name
import
NameSet
import
Literal
import
TyCon
import
GHC.Core.
TyCon
import
FastString
import
GHC.StgToCmm.Layout
(
ArgRep
(
..
)
)
import
GHC.Runtime.Heap.Layout
...
...
compiler/GHC/ByteCode/InfoTable.hs
View file @
18a346a4
...
...
@@ -17,8 +17,8 @@ import GHC.Driver.Session
import
GHC.Driver.Types
import
Name
(
Name
,
getName
)
import
NameEnv
import
DataCon
(
DataCon
,
dataConRepArgTys
,
dataConIdentity
)
import
TyCon
(
TyCon
,
tyConFamilySize
,
isDataTyCon
,
tyConDataCons
)
import
GHC.Core.
DataCon
(
DataCon
,
dataConRepArgTys
,
dataConIdentity
)
import
GHC.Core.
TyCon
(
TyCon
,
tyConFamilySize
,
isDataTyCon
,
tyConDataCons
)
import
GHC.Types.RepType
import
GHC.StgToCmm.Layout
(
mkVirtConstrSizes
)
import
GHC.StgToCmm.Closure
(
tagForCon
,
NonVoid
(
..
)
)
...
...
compiler/GHC/ByteCode/Instr.hs
View file @
18a346a4
...
...
@@ -25,7 +25,7 @@ import Unique
import
Id
import
GHC.Core
import
Literal
import
DataCon
import
GHC.Core.
DataCon
import
VarSet
import
PrimOp
import
GHC.Runtime.Heap.Layout
...
...
compiler/GHC/ByteCode/Types.hs
View file @
18a346a4
...
...
@@ -22,7 +22,7 @@ import NameEnv
import
Outputable
import
PrimOp
import
SizedSeq
import
Type
import
GHC.Core.
Type
import
SrcLoc
import
GHCi.BreakArray
import
GHCi.RemoteTypes
...
...
compiler/GHC/Cmm/Utils.hs
View file @
18a346a4
...
...
@@ -72,7 +72,7 @@ module GHC.Cmm.Utils(
import
GhcPrelude
import
TyCon
(
PrimRep
(
..
),
PrimElemRep
(
..
)
)
import
GHC.Core.
TyCon
(
PrimRep
(
..
),
PrimElemRep
(
..
)
)
import
GHC.Types.RepType
(
UnaryType
,
SlotTy
(
..
),
typePrimRep1
)
import
GHC.Runtime.Heap.Layout
...
...
compiler/GHC/Core.hs
View file @
18a346a4
...
...
@@ -104,13 +104,13 @@ import GhcPrelude
import
CostCentre
import
VarEnv
(
InScopeSet
)
import
Var
import
Type
import
Coercion
import
GHC.Core.
Type
import
GHC.Core.
Coercion
import
Name
import
NameSet
import
NameEnv
(
NameEnv
,
emptyNameEnv
)
import
Literal
import
DataCon
import
GHC.Core.
DataCon
import
Module
import
BasicTypes
import
GHC.Driver.Session
...
...
compiler/GHC/Core/Arity.hs
View file @
18a346a4
...
...
@@ -31,10 +31,10 @@ import Demand
import
Var
import
VarEnv
import
Id
import
Type
import
TyCon
(
initRecTc
,
checkRecTc
)
import
Predicate
(
isDictTy
)
import
Coercion
import
GHC.Core.Type
as
Type
import
GHC.Core.
TyCon
(
initRecTc
,
checkRecTc
)
import
GHC.Core.
Predicate
(
isDictTy
)
import
GHC.Core.Coercion
as
Coercion
import
BasicTypes
import
Unique
import
GHC.Driver.Session
(
DynFlags
,
GeneralFlag
(
..
),
gopt
)
...
...
@@ -130,7 +130,7 @@ typeArity ty
|
Just
(
tc
,
tys
)
<-
splitTyConApp_maybe
ty
,
Just
(
ty'
,
_
)
<-
instNewTyCon_maybe
tc
tys
,
Just
rec_nts'
<-
checkRecTc
rec_nts
tc
-- See Note [Expanding newtypes]
-- in TyCon
-- in
GHC.Core.
TyCon
-- , not (isClassTyCon tc) -- Do not eta-expand through newtype classes
-- -- See Note [Newtype classes and eta expansion]
-- (no longer required)
...
...
compiler/
types
/Class.hs
→
compiler/
GHC/Core
/Class.hs
View file @
18a346a4
...
...
@@ -5,7 +5,7 @@
{-# LANGUAGE CPP #-}
module
Class
(
module
GHC.Core.
Class
(
Class
,
ClassOpItem
,
ClassATItem
(
..
),
...
...
@@ -25,9 +25,9 @@ module Class (
import
GhcPrelude
import
{-#
SOURCE
#-
}
TyCon
(
TyCon
)
import
{-#
SOURCE
#-
}
TyCoRep
(
Type
,
PredType
)
import
{-#
SOURCE
#-
}
TyCoPpr
(
pprType
)
import
{-#
SOURCE
#-
}
GHC
.
Core
.
TyCon
(
TyCon
)
import
{-#
SOURCE
#-
}
GHC
.
Core
.
TyCo
.
Rep
(
Type
,
PredType
)
import
{-#
SOURCE
#-
}
GHC
.
Core
.
TyCo
.
Ppr
(
pprType
)
import
Var
import
Name
import
BasicTypes
...
...
@@ -53,7 +53,7 @@ data Class
=
Class
{
classTyCon
::
TyCon
,
-- The data type constructor for
-- dictionaries of this class
-- See Note [ATyCon for classes] in TyCoRep
-- See Note [ATyCon for classes] in
GHC.Core.
TyCo
.
Rep
className
::
Name
,
-- Just the cached name of the TyCon
classKey
::
Unique
,
-- Cached unique of TyCon
...
...
compiler/
types
/Coercion.hs
→
compiler/
GHC/Core
/Coercion.hs
View file @
18a346a4
...
...
@@ -9,7 +9,7 @@
-- as used in System FC. See 'GHC.Core.Expr' for
-- more on System FC and how coercions fit into it.
--
module
Coercion
(
module
GHC.Core.
Coercion
(
-- * Main data type
Coercion
,
CoercionN
,
CoercionR
,
CoercionP
,
MCoercion
(
..
),
MCoercionR
,
UnivCoProvenance
,
CoercionHole
(
..
),
coHoleCoVar
,
setCoHoleCoVar
,
...
...
@@ -121,14 +121,14 @@ import {-# SOURCE #-} GHC.CoreToIface (toIfaceTyCon, tidyToIfaceTcArgs)
import
GhcPrelude
import
GHC.Iface.Type
import
TyCoRep
import
TyCoFVs
import
TyCoPpr
import
TyCoSubst
import
TyCoTidy
import
Type
import
TyCon
import
Co
Axiom
import
GHC.Core.
TyCo
.
Rep
import
GHC.Core.
TyCo
.
FVs
import
GHC.Core.
TyCo
.
Ppr
import
GHC.Core.
TyCo
.
Subst
import
GHC.Core.
TyCo
.
Tidy
import
GHC.Core.
Type
import
GHC.Core.
TyCon
import
GHC.Core.Coercion.
Axiom
import
Var
import
VarEnv
import
VarSet
...
...
@@ -155,7 +155,7 @@ import Data.Char( isDigit )
-- The coercion arguments always *precisely* saturate
-- arity of (that branch of) the CoAxiom. If there are
-- any left over, we use AppCo. See
-- See [Coercion axioms applied to coercions] in TyCoRep
-- See [Coercion axioms applied to coercions] in
GHC.Core.
TyCo
.
Rep
\subsection{Coercion variables}
%* *
...
...
@@ -185,7 +185,7 @@ Defined here to avoid module loops. CoAxiom is loaded very early on.
etaExpandCoAxBranch
::
CoAxBranch
->
([
TyVar
],
[
Type
],
Type
)
-- Return the (tvs,lhs,rhs) after eta-expanding,
-- to the way in which the axiom was originally written
-- See Note [Eta reduction for data families] in
Co
Axiom
-- See Note [Eta reduction for data families] in
GHC.Core.Coercion.
Axiom
etaExpandCoAxBranch
(
CoAxBranch
{
cab_tvs
=
tvs
,
cab_eta_tvs
=
eta_tvs
,
cab_lhs
=
lhs
...
...
@@ -241,7 +241,7 @@ ppr_co_ax_branch ppr_rhs fam_tc branch
-- Eta-expand LHS and RHS types, because sometimes data family
-- instances are eta-reduced.
-- See Note [Eta reduction for data families] in FamInstEnv.
-- See Note [Eta reduction for data families] in
GHC.Core.
FamInstEnv.
(
ee_tvs
,
ee_lhs
,
ee_rhs
)
=
etaExpandCoAxBranch
branch
pp_lhs
=
pprIfaceTypeApp
topPrec
(
toIfaceTyCon
fam_tc
)
...
...
@@ -330,7 +330,7 @@ Suppose we have this:
(f |> co) t1 .. tn
Then we want to push the coercion into the arguments, so as to make
progress. For example of why you might want to do so, see Note
[Respecting definitional equality] in TyCoRep.
[Respecting definitional equality] in
GHC.Core.
TyCo
.
Rep.
This is done by decomposePiCos. Specifically, if
decomposePiCos co [t1,..,tn] = ([co1,...,cok], cor)
...
...
@@ -732,7 +732,7 @@ mkAppCo (TyConAppCo r tc args) arg
mkAppCo
co
arg
=
AppCo
co
arg
-- Note, mkAppCo is careful to maintain invariants regarding
-- where Refl constructors appear; see the comments in the definition
-- of Coercion and the Note [Refl invariant] in TyCoRep.
-- of Coercion and the Note [Refl invariant] in
GHC.Core.
TyCo
.
Rep.
-- | Applies multiple 'Coercion's to another 'Coercion', from left to right.
-- See also 'mkAppCo'.
...
...
@@ -743,8 +743,8 @@ mkAppCos co1 cos = foldl' mkAppCo co1 cos
{- Note [Unused coercion variable in ForAllCo]
See Note [Unused coercion variable in ForAllTy] in TyCoRep for the
motivation for
checking coercion variable in types.
See Note [Unused coercion variable in ForAllTy] in
GHC.Core.
TyCo
.
Rep for the
motivation for
checking coercion variable in types.
To lift the design choice to (ForAllCo cv kind_co body_co), we have two options:
(1) In mkForAllCo, we check whether cv is a coercion variable
...
...
@@ -1367,7 +1367,7 @@ promoteCoercion co = case co of
ForAllCo
_
_
_
->
ASSERT
(
False
)
mkNomReflCo
liftedTypeKind
-- See Note [Weird typing rule for ForAllTy] in Type
-- See Note [Weird typing rule for ForAllTy] in
GHC.Core.
Type
FunCo
_
_
_
->
ASSERT
(
False
)
...
...
@@ -1416,7 +1416,7 @@ promoteCoercion co = case co of
|
otherwise
->
ASSERT
(
False
)
mkNomReflCo
liftedTypeKind
-- See Note [Weird typing rule for ForAllTy] in Type
-- See Note [Weird typing rule for ForAllTy] in
GHC.Core.
Type
KindCo
_
->
ASSERT
(
False
)
...
...
@@ -1486,7 +1486,7 @@ castCoercionKindI g h1 h2
=
mkCoherenceRightCo
r
t2
h2
(
mkCoherenceLeftCo
r
t1
h1
g
)
where
(
Pair
t1
t2
,
r
)
=
coercionKindRole
g
-- See note [Newtype coercions] in TyCon
-- See note [Newtype coercions] in
GHC.Core.
TyCon
mkPiCos
::
Role
->
[
Var
]
->
Coercion
->
Coercion
mkPiCos
r
vs
co
=
foldr
(
mkPiCo
r
)
co
vs
...
...
@@ -1743,8 +1743,8 @@ This follows the lifting context extension definition in the
data
LiftingContext
=
LC
TCvSubst
LiftCoEnv
-- in optCoercion, we need to lift when optimizing InstCo.
-- See Note [Optimising InstCo] in
Opt
Coercion
-- We thus propagate the substitution from
Opt
Coercion here.
-- See Note [Optimising InstCo] in
GHC.Core.
Coercion
.Opt
-- We thus propagate the substitution from
GHC.Core.
Coercion
.Opt
here.
instance
Outputable
LiftingContext
where
ppr
(
LC
_
env
)
=
hang
(
text
"LiftingContext:"
)
2
(
ppr
env
)
...
...
@@ -1912,7 +1912,7 @@ Note [liftCoSubstTyVar]
This function can fail if a coercion in the environment is of too low a role.
liftCoSubstTyVar is called from two places: in liftCoSubst (naturally), and
also in matchAxiom in
Opt
Coercion. From liftCoSubst, the so-called lifting
also in matchAxiom in
GHC.Core.
Coercion.
Opt.
From liftCoSubst, the so-called lifting
lemma guarantees that the roles work out. If we fail in this
case, we really should panic -- something is deeply wrong. But, in matchAxiom,
failing is fine. matchAxiom is trying to find a set of coercions
...
...
@@ -2423,7 +2423,8 @@ mkReprPrimEqPred ty1 ty2
-- | Assuming that two types are the same, ignoring coercions, find
-- a nominal coercion between the types. This is useful when optimizing
-- transitivity over coercion applications, where splitting two
-- AppCos might yield different kinds. See Note [EtaAppCo] in OptCoercion.
-- AppCos might yield different kinds. See Note [EtaAppCo] in
-- GHC.Core.Coercion.Opt.
buildCoercion
::
Type
->
Type
->
CoercionN
buildCoercion
orig_ty1
orig_ty2
=
go
orig_ty1
orig_ty2
where
...
...
@@ -2792,7 +2793,7 @@ is `k -> Any @a`, and thus the third argument of `x :: k` is well-kinded.
-}
-- This is shared between the flattener and the normaliser in FamInstEnv.
-- This is shared between the flattener and the normaliser in
GHC.Core.
FamInstEnv.
-- See Note [simplifyArgsWorker]
{-# INLINE simplifyArgsWorker #-}
simplifyArgsWorker
::
[
TyCoBinder
]
->
Kind
...
...
compiler/
types
/Coercion.hs-boot
→
compiler/
GHC/Core
/Coercion.hs-boot
View file @
18a346a4
{-# LANGUAGE FlexibleContexts #-}
module
Coercion
where
module
GHC.Core.
Coercion
where
import
GhcPrelude
import
{-#
SOURCE
#-
}
TyCoRep
import
{-#
SOURCE
#-
}
TyCon
import
{-#
SOURCE
#-
}
GHC
.
Core
.
TyCo
.
Rep
import
{-#
SOURCE
#-
}
GHC
.
Core
.
TyCon
import
BasicTypes
(
LeftOrRight
)
import
Co
Axiom
import
GHC.Core.Coercion.
Axiom
import
Var
import
Pair
import
Util
...
...
compiler/
types/Co
Axiom.hs
→
compiler/
GHC/Core/Coercion/
Axiom.hs
View file @
18a346a4
...
...
@@ -6,7 +6,7 @@
-- | Module for coercion axioms, used to represent type family instances
-- and newtypes
module
Co
Axiom
(
module
GHC.Core.Coercion.
Axiom
(
BranchFlag
,
Branched
,
Unbranched
,
BranchIndex
,
Branches
(
..
),
manyBranches
,
unbranched
,
fromBranches
,
numBranches
,
...
...
@@ -31,9 +31,9 @@ module CoAxiom (
import
GhcPrelude
import
{-#
SOURCE
#-
}
TyCoRep
(
Type
)
import
{-#
SOURCE
#-
}
TyCoPpr
(
pprType
)
import
{-#
SOURCE
#-
}
TyCon
(
TyCon
)
import
{-#
SOURCE
#-
}
GHC
.
Core
.
TyCo
.
Rep
(
Type
)
import
{-#
SOURCE
#-
}
GHC
.
Core
.
TyCo
.
Ppr
(
pprType
)
import
{-#
SOURCE
#-
}
GHC
.
Core
.
TyCon
(
TyCon
)
import
Outputable
import
FastString
import
Name
...
...
@@ -87,7 +87,7 @@ can unify with the supplied arguments. After all, it is possible that some
of the type arguments are lambda-bound type variables whose instantiation may
cause an earlier match among the branches. We wish to prohibit this behavior,
so the type checker rules out the choice of a branch where a previous branch
can unify. See also [Apartness] in FamInstEnv.
hs.
can unify. See also [Apartness] in
GHC.Core.
FamInstEnv.
For example, the following is malformed, where 'a' is a lambda-bound type
variable:
...
...
@@ -306,7 +306,7 @@ isImplicitCoAxiom = co_ax_implicit
coAxBranchIncomps
::
CoAxBranch
->
[
CoAxBranch
]
coAxBranchIncomps
=
cab_incomps
-- See Note [Compatibility checking] in FamInstEnv
-- See Note [Compatibility checking] in
GHC.Core.
FamInstEnv
placeHolderIncomps
::
[
CoAxBranch
]
placeHolderIncomps
=
panic
"placeHolderIncomps"
...
...
@@ -431,7 +431,7 @@ looked like
(See #9692, #14179, and #15845 for examples of what can go wrong if
we don't eta-expand when showing things to the user.)
(See also Note [Newtype eta] in TyCon. This is notionally separate
(See also Note [Newtype eta] in
GHC.Core.
TyCon. This is notionally separate
and deals with the axiom connecting a newtype with its representation
type; but it too is eta-reduced.)
-}
...
...
@@ -473,8 +473,8 @@ instance Outputable CoAxBranch where
Roles are defined here to avoid circular dependencies.
-}
-- See Note [Roles] in Coercion
-- defined here to avoid cyclic dependency with Coercion
-- See Note [Roles] in
GHC.Core.
Coercion
-- defined here to avoid cyclic dependency with
GHC.Core.
Coercion
--
-- Order of constructors matters: the Ord instance coincides with the *super*typing
-- relation on roles.
...
...
compiler/
types/Opt
Coercion.hs
→
compiler/
GHC/Core/
Coercion
/Opt
.hs
View file @
18a346a4
...
...
@@ -2,29 +2,29 @@
{-# LANGUAGE CPP #-}
module
Opt
Coercion
(
optCoercion
,
checkAxInstCo
)
where
module
GHC.Core.
Coercion
.Opt
(
optCoercion
,
checkAxInstCo
)
where
#
include
"HsVersions.h"
import
GhcPrelude
import
GHC.Driver.Session
import
TyCoRep
import
TyCoSubst
import
Coercion
import
Type
hiding
(
substTyVarBndr
,
substTy
)
import
GHC.Core.
TyCo
.
Rep
import
GHC.Core.
TyCo
.
Subst
import
GHC.Core.
Coercion
import
GHC.Core.Type
as
Type
hiding
(
substTyVarBndr
,
substTy
)
import
TcType
(
exactTyCoVarsOfType
)
import
TyCon
import
Co
Axiom
import
GHC.Core.
TyCon
import
GHC.Core.Coercion.
Axiom
import
VarSet
import
VarEnv
import
Outputable
import
FamInstEnv
(
flattenTys
)
import
GHC.Core.
FamInstEnv
(
flattenTys
)
import
Pair
import
ListSetOps
(
getNth
)
import
Util
import
Unify
import
InstEnv
import
GHC.Core.
Unify
import
GHC.Core.
InstEnv
import
Control.Monad
(
zipWithM
)
{-
...
...
@@ -75,7 +75,7 @@ If we substitute the *type* tv for the *coercion*
(g2 ; t2 ~ t2 |> sym h) in g, we'll get this result exactly.
This is bizarre,
though, because we're substituting a type variable with a coercion. However,
this operation already exists: it's called *lifting*, and defined in Coercion.
this operation already exists: it's called *lifting*, and defined in
GHC.Core.
Coercion.
We just need to enhance the lifting operation to be able to deal with
an ambient substitution, which is why a LiftingContext stores a TCvSubst.
...
...
@@ -462,7 +462,7 @@ If we have (c :: t~t) we can optimise it to Refl. That increases the
chances of floating the Refl upwards; e.g. Maybe c --> Refl (Maybe t)
We do so here in optCoercion, not in mkCoVarCo; see Note [mkCoVarCo]
in Coercion.
in
GHC.Core.
Coercion.
-}
-------------
...
...
@@ -930,7 +930,7 @@ First, convince yourself of the following:
(a |> (h -> <Type>)) (b |> h) `eqType` a b
That last fact is due to Note [Non-trivial definitional equality] in TyCoRep,
That last fact is due to Note [Non-trivial definitional equality] in
GHC.Core.
TyCo
.
Rep,
where we ignore coercions in types as long as two types' kinds are the same.
In our case, we meet this last condition, because
...
...
@@ -965,7 +965,7 @@ The problem described here was first found in dependent/should_compile/dynamic-p
-- Returns the conflicting branch, if it exists
-- See Note [Conflict checking with AxiomInstCo]
checkAxInstCo
::
Coercion
->
Maybe
CoAxBranch
-- defined here to avoid dependencies in Coercion
-- defined here to avoid dependencies in
GHC.Core.
Coercion
-- If you edit this function, you may need to update the GHC formalism
-- See Note [GHC Formalism] in GHC.Core.Lint
checkAxInstCo
(
AxiomInstCo
ax
ind
cos
)
...
...
@@ -986,7 +986,7 @@ checkAxInstCo (AxiomInstCo ax ind cos)
check_no_conflict
::
[
Type
]
->
[
CoAxBranch
]
->
Maybe
CoAxBranch
check_no_conflict
_
[]
=
Nothing
check_no_conflict
flat
(
b
@
CoAxBranch
{
cab_lhs
=
lhs_incomp
}
:
rest
)
-- See Note [Apartness] in FamInstEnv
-- See Note [Apartness] in
GHC.Core.
FamInstEnv
|
SurelyApart
<-
tcUnifyTysFG
instanceBindFun
flat
lhs_incomp
=
check_no_conflict
flat
rest
|
otherwise
...
...
@@ -1162,7 +1162,7 @@ etaTyConAppCo_maybe tc co
,
Just
(
tc1
,
tys1
)
<-
splitTyConApp_maybe
ty1
,
Just
(
tc2
,
tys2
)
<-
splitTyConApp_maybe
ty2
,
tc1
==
tc2
,
isInjectiveTyCon
tc
r
-- See Note [NthCo and newtypes] in TyCoRep
,
isInjectiveTyCon
tc
r
-- See Note [NthCo and newtypes] in
GHC.Core.
TyCo
.
Rep
,
let
n
=
length
tys1
,
tys2
`
lengthIs
`
n
-- This can fail in an erroneous program
-- E.g. T a ~# T a b
...
...
compiler/
basicTypes
/ConLike.hs
→
compiler/
GHC/Core
/ConLike.hs
View file @
18a346a4
...
...
@@ -7,7 +7,7 @@
{-# LANGUAGE CPP #-}
module
ConLike
(
module
GHC.Core.
ConLike
(
ConLike
(
..
)
,
conLikeArity
,
conLikeFieldLabels
...
...
@@ -28,16 +28,16 @@ module ConLike (
import
GhcPrelude
import
DataCon
import
PatSyn
import
GHC.Core.
DataCon
import
GHC.Core.
PatSyn
import
Outputable
import
Unique
import
Util
import
Name
import
BasicTypes
import
TyCoRep
(
Type
,
ThetaType
)
import
GHC.Core.
TyCo
.
Rep
(
Type
,
ThetaType
)
import
Var
import
Type
(
mkTyConApp
)
import
GHC.Core.
Type
(
mkTyConApp
)
import
qualified
Data.Data
as
Data
...
...
@@ -167,7 +167,7 @@ conLikeResTy (PatSynCon ps) tys = patSynInstResTy ps tys
conLikeFullSig
::
ConLike
->
([
TyVar
],
[
TyCoVar
],
[
EqSpec
]
-- Why tyvars for universal but tycovars for existential?
-- See Note [Existential coercion variables] in DataCon
-- See Note [Existential coercion variables] in
GHC.Core.
DataCon
,
ThetaType
,
ThetaType
,
[
Type
],
Type
)
conLikeFullSig
(
RealDataCon
con
)
=
let
(
univ_tvs
,
ex_tvs
,
eq_spec
,
theta
,
arg_tys
,
res_ty
)
=
dataConFullSig
con
...
...
compiler/
basicTypes
/ConLike.hs-boot
→
compiler/
GHC/Core
/ConLike.hs-boot
View file @
18a346a4
module
ConLike
where
import
{-#
SOURCE
#-
}
DataCon
(
DataCon
)
import
{-#
SOURCE
#-
}
PatSyn
(
PatSyn
)
module
GHC.Core.
ConLike
where
import
{-#
SOURCE
#-
}
GHC
.
Core
.
DataCon
(
DataCon
)
import
{-#
SOURCE
#-
}
GHC
.
Core
.
PatSyn
(
PatSyn
)
import
Name
(
Name
)
data
ConLike
=
RealDataCon
DataCon
...
...
compiler/
basicTypes
/DataCon.hs
→
compiler/
GHC/Core
/DataCon.hs
View file @
18a346a4
...
...
@@ -7,7 +7,7 @@
{-# LANGUAGE CPP, DeriveDataTypeable #-}
module
DataCon
(
module
GHC.Core.
DataCon
(
-- * Main data types
DataCon
,
DataConRep
(
..
),
SrcStrictness
(
..
),
SrcUnpackedness
(
..
),
...
...
@@ -64,15 +64,15 @@ module DataCon (
import
GhcPrelude
import
{-#
SOURCE
#-
}
MkId
(
DataConBoxer
)
import
Type
import
Coercion
import
Unify
import
TyCon
import
GHC.Core.Type
as
Type
import
GHC.Core.
Coercion
import
GHC.Core.
Unify
import
GHC.Core.
TyCon
import
FieldLabel
import
Class
import
GHC.Core.
Class
import
Name
import
PrelNames
import
Predicate
import
GHC.Core.
Predicate
import
Var
import
Outputable
import
Util
...
...
@@ -469,7 +469,7 @@ data DataCon
-- The actual fixity is stored elsewhere
dcPromoted
::
TyCon
-- The promoted TyCon
-- See Note [Promoted data constructors] in TyCon
-- See Note [Promoted data constructors] in
GHC.Core.
TyCon
}
...
...
@@ -479,7 +479,7 @@ For the TyVarBinders in a DataCon and PatSyn:
* Each argument flag is Inferred or Specified.
None are Required. (A DataCon is a term-level function; see
Note [No Required TyCoBinder in terms] in TyCoRep.)
Note [No Required TyCoBinder in terms] in
GHC.Core.
TyCo
.
Rep.)
Why do we need the TyVarBinders, rather than just the TyVars? So that
we can construct the right type for the DataCon with its foralls
...
...
@@ -961,7 +961,7 @@ mkDataCon name declared_infix prom_info
mkVisFunTys
rep_arg_tys
$
mkTyConApp
rep_tycon
(
mkTyVarTys
univ_tvs
)
-- See Note [Promoted data constructors] in TyCon
-- See Note [Promoted data constructors] in
GHC.Core.
TyCon
prom_tv_bndrs
=
[
mkNamedTyConBinder
vis
tv
|
Bndr
tv
vis
<-
user_tvbs
]
...
...
compiler/
basicTypes
/DataCon.hs-boot
→
compiler/
GHC/Core
/DataCon.hs-boot
View file @
18a346a4
module
DataCon
where
module
GHC.Core.
DataCon
where
import
GhcPrelude
import
Var
(
TyVar
,
TyCoVar
,
TyVarBinder
)
import
Name
(
Name
,
NamedThing
)
import
{-#
SOURCE
#-
}
TyCon
(
TyCon
)
import
{-#
SOURCE
#-
}
GHC
.
Core
.
TyCon
(
TyCon
)
import
FieldLabel
(
FieldLabel
)
import
Unique
(
Uniquable
)
import
Outputable
(
Outputable
,
OutputableBndr
)
import
BasicTypes
(
Arity
)
import
{-#
SOURCE
#-
}
TyCoRep
(
Type
,
ThetaType
)
import
{-#
SOURCE
#-
}
GHC
.
Core
.
TyCo
.
Rep
(
Type
,
ThetaType
)
data
DataCon
data
DataConRep
...
...
compiler/GHC/Core/FVs.hs
View file @
18a346a4
...
...
@@ -70,12 +70,12 @@ import Unique (Uniquable (..))
import
Name
import
VarSet
import
Var
import
Type
import
TyCoRep
import
TyCoFVs