Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gesh
GHC
Commits
5bb39849
Commit
5bb39849
authored
27 years ago
by
sof
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 1997-07-05 02:25:45 by sof]
parent
3a3a71aa
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ghc/compiler/typecheck/TcTyClsDecls.lhs
+15
-17
15 additions, 17 deletions
ghc/compiler/typecheck/TcTyClsDecls.lhs
ghc/compiler/typecheck/TcTyDecls.lhs
+6
-8
6 additions, 8 deletions
ghc/compiler/typecheck/TcTyDecls.lhs
with
21 additions
and
25 deletions
ghc/compiler/typecheck/TcTyClsDecls.lhs
+
15
−
17
View file @
5bb39849
...
...
@@ -50,36 +50,34 @@ import Util ( panic{-, pprTrace-} )
The main function
~~~~~~~~~~~~~~~~~
\begin{code}
tcTyAndClassDecls1 :: InstanceMapper
tcTyAndClassDecls1 ::
TcEnv s ->
InstanceMapper
-- Knot tying stuff
-> [RenamedHsDecl]
-> TcM s (TcEnv s)
tcTyAndClassDecls1 inst_mapper decls
tcTyAndClassDecls1
unf_env
inst_mapper decls
= sortByDependency decls `thenTc` \ groups ->
tcGroups inst_mapper groups
tcGroups
unf_env
inst_mapper groups
tcGroups inst_mapper []
tcGroups
unf_env
inst_mapper []
= tcGetEnv `thenNF_Tc` \ env ->
returnTc env
tcGroups inst_mapper (group:groups)
= tcGroup inst_mapper group `thenTc` \ new_env ->
tcGroups
unf_env
inst_mapper (group:groups)
= tcGroup
unf_env
inst_mapper group `thenTc` \ new_env ->
-- Extend the environment using the new tycons and classes
tcSetEnv new_env $
-- Do the remaining groups
tcGroups inst_mapper groups
tcGroups
unf_env
inst_mapper groups
\end{code}
Dealing with a group
~~~~~~~~~~~~~~~~~~~~
\begin{code}
tcGroup :: InstanceMapper -> Bag RenamedHsDecl -> TcM s (TcEnv s)
tcGroup inst_mapper decls
= -- pprTrace "tcGroup: " (hsep (map (fst.fmt_decl) (bagToList decls))) $
-- TIE THE KNOT
tcGroup :: TcEnv s -> InstanceMapper -> Bag RenamedHsDecl -> TcM s (TcEnv s)
tcGroup unf_env inst_mapper decls
= -- TIE THE KNOT
fixTc ( \ ~(tycons,classes,_) ->
-- EXTEND TYPE AND CLASS ENVIRONMENTS
...
...
@@ -93,7 +91,7 @@ tcGroup inst_mapper decls
tcTyVarScope tyvar_names ( \ tyvars ->
-- DEAL WITH THE DEFINITIONS THEMSELVES
foldBag combine (tcDecl inst_mapper)
foldBag combine (tcDecl
unf_env
inst_mapper)
(returnTc (emptyBag, emptyBag))
decls
) `thenTc` \ (tycon_bag,class_bag) ->
...
...
@@ -122,16 +120,16 @@ tcGroup inst_mapper decls
Dealing with one decl
~~~~~~~~~~~~~~~~~~~~~
\begin{code}
tcDecl :: InstanceMapper
tcDecl ::
TcEnv s ->
InstanceMapper
-> RenamedHsDecl
-> TcM s (Bag TyCon, Bag Class)
tcDecl inst_mapper (TyD decl)
tcDecl
unf_env
inst_mapper (TyD decl)
= tcTyDecl decl `thenTc` \ tycon ->
returnTc (unitBag tycon, emptyBag)
tcDecl inst_mapper (ClD decl)
= tcClassDecl1 inst_mapper decl `thenTc` \ clas ->
tcDecl
unf_env
inst_mapper (ClD decl)
= tcClassDecl1
unf_env
inst_mapper decl `thenTc` \ clas ->
returnTc (emptyBag, unitBag clas)
\end{code}
...
...
This diff is collapsed.
Click to expand it.
ghc/compiler/typecheck/TcTyDecls.lhs
+
6
−
8
View file @
5bb39849
...
...
@@ -17,14 +17,14 @@ IMP_Ubiq(){-uitous-}
import HsSyn ( TyDecl(..), ConDecl(..), ConDetails(..), BangType(..), HsExpr(..),
Match(..), GRHSsAndBinds(..), GRHS(..), OutPat(..),
HsBinds(..), HsLit, Stmt, DoOrListComp, ArithSeqInfo,
SYN_IE(RecFlag), nonRecursive,
SYN_IE(RecFlag), nonRecursive,
andMonoBinds,
HsType, Fake, InPat, HsTyVar, Fixity,
MonoBinds(..), Sig
)
import HsTypes ( getTyVarName )
import RnHsSyn ( RenamedTyDecl(..), RenamedConDecl(..) )
import TcHsSyn ( mkHsTyLam, mkHsDictLam, tcIdType,
SYN_IE(TcHsBinds), TcIdOcc(..)
SYN_IE(TcHsBinds), TcIdOcc(..)
, SYN_IE(TcMonoBinds)
)
import Inst ( newDicts, InstOrigin(..), Inst )
import TcMonoType ( tcHsTypeKind, tcHsType, tcContext )
...
...
@@ -168,13 +168,13 @@ Generating constructor/selector bindings for data declarations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{code}
mkDataBinds :: [TyCon] -> TcM s ([Id], Tc
Hs
Binds s)
mkDataBinds [] = returnTc ([], EmptyBinds)
mkDataBinds :: [TyCon] -> TcM s ([Id], Tc
Mono
Binds s)
mkDataBinds [] = returnTc ([], Empty
Mono
Binds)
mkDataBinds (tycon : tycons)
| isSynTyCon tycon = mkDataBinds tycons
| otherwise = mkDataBinds_one tycon `thenTc` \ (ids1, b1) ->
mkDataBinds tycons `thenTc` \ (ids2, b2) ->
returnTc (ids1++ids2, b1 `
Then
Binds` b2)
returnTc (ids1++ids2, b1 `
AndMono
Binds` b2)
mkDataBinds_one tycon
= ASSERT( isAlgTyCon tycon )
...
...
@@ -189,9 +189,7 @@ mkDataBinds_one tycon
| data_id <- data_ids, isLocallyDefined data_id
]
in
returnTc (data_ids,
MonoBind (foldr AndMonoBinds EmptyMonoBinds binds) [] nonRecursive
)
returnTc (data_ids, andMonoBinds binds)
where
data_cons = tyConDataCons tycon
fields = [ (con, field) | con <- data_cons,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment