Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4,252
Issues
4,252
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
397
Merge Requests
397
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
8406c69e
Commit
8406c69e
authored
Feb 23, 2007
by
chak@cse.unsw.edu.au.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved argument position info of ATs into tycon rhs info
parent
2c634afb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
63 deletions
+69
-63
compiler/iface/BuildTyCl.lhs
compiler/iface/BuildTyCl.lhs
+3
-3
compiler/iface/MkIface.lhs
compiler/iface/MkIface.lhs
+7
-7
compiler/iface/TcIface.lhs
compiler/iface/TcIface.lhs
+1
-1
compiler/typecheck/TcTyClsDecls.lhs
compiler/typecheck/TcTyClsDecls.lhs
+5
-5
compiler/types/TyCon.lhs
compiler/types/TyCon.lhs
+53
-47
No files found.
compiler/iface/BuildTyCl.lhs
View file @
8406c69e
...
...
@@ -37,7 +37,7 @@ import Data.List
\begin{code}
------------------------------------------------------
buildSynTyCon :: Name -> [TyVar] -> SynTyConRhs -> TyCon
buildSynTyCon name tvs rhs@(OpenSynTyCon rhs_ki)
buildSynTyCon name tvs rhs@(OpenSynTyCon rhs_ki
_
)
= mkSynTyCon name kind tvs rhs
where
kind = mkArrowKinds (map tyVarKind tvs) rhs_ki
...
...
@@ -100,10 +100,10 @@ mkAbstractTyConRhs :: AlgTyConRhs
mkAbstractTyConRhs = AbstractTyCon
mkOpenDataTyConRhs :: AlgTyConRhs
mkOpenDataTyConRhs = Open
DataTyCon
mkOpenDataTyConRhs = Open
TyCon Nothing False
mkOpenNewTyConRhs :: AlgTyConRhs
mkOpenNewTyConRhs = Open
NewTyCon
mkOpenNewTyConRhs = Open
TyCon Nothing True
mkDataTyConRhs :: [DataCon] -> AlgTyConRhs
mkDataTyConRhs cons
...
...
compiler/iface/MkIface.lhs
View file @
8406c69e
...
...
@@ -1085,16 +1085,16 @@ tyThingToIfaceDecl (ATyCon tycon)
where
tyvars = tyConTyVars tycon
(syn_isOpen, syn_tyki) = case synTyConRhs tycon of
OpenSynTyCon ki -> (True , ki)
SynonymTyCon ty -> (False, ty)
OpenSynTyCon ki
_
-> (True , ki)
SynonymTyCon ty
-> (False, ty)
ifaceConDecls (NewTyCon { data_con = con }) =
ifaceConDecls (NewTyCon { data_con = con })
=
IfNewTyCon (ifaceConDecl con)
ifaceConDecls (DataTyCon { data_cons = cons }) =
ifaceConDecls (DataTyCon { data_cons = cons })
=
IfDataTyCon (map ifaceConDecl cons)
ifaceConDecls Open
DataTyCon
= IfOpenDataTyCon
ifaceConDecls Open
NewTyCon
= IfOpenNewTyCon
ifaceConDecls AbstractTyCon = IfAbstractTyCon
ifaceConDecls Open
TyCon { otIsNewtype = False }
= IfOpenDataTyCon
ifaceConDecls Open
TyCon { otIsNewtype = True }
= IfOpenNewTyCon
ifaceConDecls AbstractTyCon
= IfAbstractTyCon
-- The last case happens when a TyCon has been trimmed during tidying
-- Furthermore, tyThingToIfaceDecl is also used
-- in TcRnDriver for GHCi, when browsing a module, in which case the
...
...
compiler/iface/TcIface.lhs
View file @
8406c69e
...
...
@@ -380,7 +380,7 @@ tcIfaceDecl ignore_prags
= bindIfaceTyVars tv_bndrs $ \ tyvars -> do
{ tc_name <- lookupIfaceTop occ_name
; rhs_tyki <- tcIfaceType rdr_rhs_ty
; let rhs = if isOpen then OpenSynTyCon rhs_tyki
; let rhs = if isOpen then OpenSynTyCon rhs_tyki
Nothing
else SynonymTyCon rhs_tyki
; return (ATyCon (buildSynTyCon tc_name tyvars rhs))
}
...
...
compiler/typecheck/TcTyClsDecls.lhs
View file @
8406c69e
...
...
@@ -615,7 +615,7 @@ tcTyClDecl1 _calc_isrec
-- Check that we don't use families without -findexed-types
; checkTc idx_tys $ badFamInstDecl tc_name
; return [ATyCon $ buildSynTyCon tc_name tvs' (OpenSynTyCon kind)]
; return [ATyCon $ buildSynTyCon tc_name tvs' (OpenSynTyCon kind
Nothing
)]
}
-- "newtype family" or "data family" declaration
...
...
@@ -634,8 +634,8 @@ tcTyClDecl1 _calc_isrec
; tycon <- buildAlgTyCon tc_name final_tvs []
(case new_or_data of
DataType ->
OpenDataTyCon
NewType ->
OpenNewTyCon
)
DataType ->
mkOpenDataTyConRhs
NewType ->
mkOpenNewTyConRhs
)
Recursive False True Nothing
; return [ATyCon tycon]
}
...
...
@@ -945,8 +945,8 @@ checkValidTyCon :: TyCon -> TcM ()
checkValidTyCon tc
| isSynTyCon tc
= case synTyConRhs tc of
OpenSynTyCon _ -> return ()
SynonymTyCon ty -> checkValidType syn_ctxt ty
OpenSynTyCon _
_
-> return ()
SynonymTyCon ty
-> checkValidType syn_ctxt ty
| otherwise
= -- Check the context on the data decl
checkValidTheta (DataTyCtxt name) (tyConStupidTheta tc) `thenM_`
...
...
compiler/types/TyCon.lhs
View file @
8406c69e
...
...
@@ -108,15 +108,6 @@ data TyCon
-- types if present
-- But not over the data constructors
tyConArgPoss :: Maybe [Int], -- for associated families: for each
-- tyvar in the AT decl, gives the
-- position of that tyvar in the class
-- argument list (starting from 0).
-- NB: Length is less than tyConArity
-- if higher kind signature.
-- NB: Just _ <=> associated (not
-- toplevel) family
algTcSelIds :: [Id], -- Its record selectors (empty if none)
algTcGadtSyntax :: Bool, -- True <=> the data type was declared using GADT syntax
...
...
@@ -158,13 +149,6 @@ data TyCon
tyConTyVars :: [TyVar], -- Bound tyvars
tyConArgPoss :: Maybe [Int], -- for associated families: for each
-- tyvar in the AT decl, gives the
-- position of that tyvar in the class
-- argument list (starting from 0).
-- NB: Length is less than tyConArity
-- if higher kind signature.
synTcRhs :: SynTyConRhs -- Expanded type in here
}
...
...
@@ -204,21 +188,37 @@ data TyCon
type FieldLabel = Name
-- Right hand sides of type constructors for algebraic types
--
data AlgTyConRhs
= AbstractTyCon -- We know nothing about this data type, except
-- that it's represented by a pointer
-- Used when we export a data type abstractly into
-- an hi file
| OpenDataTyCon -- data family (further instances can appear
| OpenNewTyCon -- newtype family at any time)
-- We know nothing about this data type, except that it's represented by a
-- pointer. Used when we export a data type abstractly into an hi file.
--
= AbstractTyCon
-- The constructor represents an open family without a fixed right hand
-- side. Additional instances can appear at any time.
--
| OpenTyCon {
otArgPoss :: Maybe [Int],
-- for associated families: for each tyvar in the AT decl, gives the
-- position of that tyvar in the class argument list (starting from 0).
-- NB: Length is less than tyConArity iff higher kind signature.
-- NB: Just _ <=> associated (not toplevel) family
otIsNewtype :: Bool
-- is a newtype (rather than data type)?
}
| DataTyCon {
data_cons :: [DataCon],
-- The constructors; can be empty if the user declares
-- the type to have no constructors
-- INVARIANT: Kept in order of increasing tag
--
(see the tag assignment in DataCon.mkDataCon)
-- (see the tag assignment in DataCon.mkDataCon)
is_enum :: Bool -- Cached: True <=> an enumeration type
} -- Includes data types with no constructors.
...
...
@@ -257,8 +257,7 @@ data AlgTyConRhs
visibleDataCons :: AlgTyConRhs -> [DataCon]
visibleDataCons AbstractTyCon = []
visibleDataCons OpenDataTyCon = []
visibleDataCons OpenNewTyCon = []
visibleDataCons OpenTyCon {} = []
visibleDataCons (DataTyCon{ data_cons = cs }) = cs
visibleDataCons (NewTyCon{ data_con = c }) = [c]
...
...
@@ -286,7 +285,14 @@ data AlgTyConParent
-- with T77's algTcParent = FamilyTyCon T [a] co
data SynTyConRhs
= OpenSynTyCon Kind -- Type family: *result* kind given
= OpenSynTyCon Kind -- Type family: *result* kind given
(Maybe [Int]) -- for associated families: for each tyvars in
-- the AT decl, gives the position of that
-- tyvar in the class argument list (starting
-- from 0).
-- NB: Length is less than tyConArity
-- if higher kind signature.
| SynonymTyCon Type -- Mentioning head type vars. Acts as a template for
-- the expansion when the tycon is applied to some
-- types.
...
...
@@ -428,7 +434,6 @@ mkAlgTyCon name kind tyvars stupid rhs sel_ids parent is_rec gen_info gadt_syn
tyConKind = kind,
tyConArity = length tyvars,
tyConTyVars = tyvars,
tyConArgPoss = Nothing,
algTcStupidTheta = stupid,
algTcRhs = rhs,
algTcSelIds = sel_ids,
...
...
@@ -498,7 +503,6 @@ mkSynTyCon name kind tyvars rhs
tyConKind = kind,
tyConArity = length tyvars,
tyConTyVars = tyvars,
tyConArgPoss = Nothing,
synTcRhs = rhs
}
...
...
@@ -556,20 +560,20 @@ isDataTyCon :: TyCon -> Bool
-- unboxed tuples
isDataTyCon tc@(AlgTyCon {algTcRhs = rhs})
= case rhs of
Open
DataTyCon -> True
Open
TyCon {} -> not (otIsNewtype rhs)
DataTyCon {} -> True
OpenNewTyCon -> False
NewTyCon {} -> False
AbstractTyCon -> False -- We don't know, so return False
AbstractTyCon -> False
-- We don't know, so return False
isDataTyCon (TupleTyCon {tyConBoxed = boxity}) = isBoxed boxity
isDataTyCon other = False
isNewTyCon :: TyCon -> Bool
isNewTyCon (AlgTyCon {algTcRhs = rhs}) = case rhs of
OpenNewTyCon -> True
NewTyCon {} -> True
_ -> False
isNewTyCon other = False
isNewTyCon (AlgTyCon {algTcRhs = rhs}) =
case rhs of
OpenTyCon {} -> otIsNewtype rhs
NewTyCon {} -> True
_ -> False
isNewTyCon other = False
-- This is an important refinement as typical newtype optimisations do *not*
-- hold for newtype families. Why? Given a type `T a', if T is a newtype
...
...
@@ -616,22 +620,24 @@ isEnumerationTyCon (AlgTyCon {algTcRhs = DataTyCon { is_enum = res }}) = res
isEnumerationTyCon other = False
isOpenTyCon :: TyCon -> Bool
isOpenTyCon (SynTyCon {synTcRhs = OpenSynTyCon _}) = True
isOpenTyCon (AlgTyCon {algTcRhs = OpenDataTyCon }) = True
isOpenTyCon (AlgTyCon {algTcRhs = OpenNewTyCon }) = True
isOpenTyCon _ = False
isOpenTyCon (SynTyCon {synTcRhs = OpenSynTyCon _ _}) = True
isOpenTyCon (AlgTyCon {algTcRhs = OpenTyCon {} }) = True
isOpenTyCon _ = False
assocTyConArgPoss_maybe :: TyCon -> Maybe [Int]
assocTyConArgPoss_maybe (AlgTyCon { tyConArgPoss = poss }) = poss
assocTyConArgPoss_maybe (SynTyCon { tyConArgPoss = poss }) = poss
assocTyConArgPoss_maybe _ = Nothing
assocTyConArgPoss_maybe (AlgTyCon {
algTcRhs = OpenTyCon {otArgPoss = poss}}) = poss
assocTyConArgPoss_maybe (SynTyCon { synTcRhs = OpenSynTyCon _ poss }) = poss
assocTyConArgPoss_maybe _ = Nothing
isTyConAssoc :: TyCon -> Bool
isTyConAssoc = isJust . assocTyConArgPoss_maybe
setTyConArgPoss :: TyCon -> [Int] -> TyCon
setTyConArgPoss tc@(AlgTyCon {}) poss = tc { tyConArgPoss = Just poss }
setTyConArgPoss tc@(SynTyCon {}) poss = tc { tyConArgPoss = Just poss }
setTyConArgPoss tc@(AlgTyCon { algTcRhs = rhs }) poss =
tc { algTcRhs = rhs {otArgPoss = Just poss} }
setTyConArgPoss tc@(SynTyCon { synTcRhs = OpenSynTyCon ki _ }) poss =
tc { synTcRhs = OpenSynTyCon ki (Just poss) }
setTyConArgPoss tc _ = pprPanic "setTyConArgPoss" (ppr tc)
isTupleTyCon :: TyCon -> Bool
...
...
@@ -769,7 +775,7 @@ tyConFamilySize :: TyCon -> Int
tyConFamilySize (AlgTyCon {algTcRhs = DataTyCon {data_cons = cons}}) =
length cons
tyConFamilySize (AlgTyCon {algTcRhs = NewTyCon {}}) = 1
tyConFamilySize (AlgTyCon {algTcRhs = Open
DataTyCon})
= 0
tyConFamilySize (AlgTyCon {algTcRhs = Open
TyCon {}})
= 0
tyConFamilySize (TupleTyCon {}) = 1
#ifdef DEBUG
tyConFamilySize other = pprPanic "tyConFamilySize:" (ppr other)
...
...
@@ -826,7 +832,7 @@ synTyConType tc = case synTcRhs tc of
_ -> pprPanic "synTyConType" (ppr tc)
synTyConResKind :: TyCon -> Kind
synTyConResKind (SynTyCon {synTcRhs = OpenSynTyCon kind}) = kind
synTyConResKind (SynTyCon {synTcRhs = OpenSynTyCon kind
_
}) = kind
synTyConResKind tycon = pprPanic "synTyConResKind" (ppr tycon)
\end{code}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment