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
ae67eed8
Commit
ae67eed8
authored
26 years ago
by
Simon Peyton Jones
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 1998-05-04 13:24:42 by simonpj]
mkRhsTyLam now does not create redundant big lambdas
parent
b117679a
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ghc/compiler/simplCore/SimplUtils.lhs
+17
-10
17 additions, 10 deletions
ghc/compiler/simplCore/SimplUtils.lhs
ghc/compiler/typecheck/TcExpr.lhs
+2
-6
2 additions, 6 deletions
ghc/compiler/typecheck/TcExpr.lhs
with
19 additions
and
16 deletions
ghc/compiler/simplCore/SimplUtils.lhs
+
17
−
10
View file @
ae67eed8
...
...
@@ -39,11 +39,13 @@ import PrelVals ( augmentId, buildId )
import PrimOp ( primOpIsCheap )
import SimplEnv
import SimplMonad
import Type ( tyVarsOfType, mkForAllTys, mkTyVarTys, getTyVar_maybe,
import Type ( tyVarsOfType,
tyVarsOfTypes,
mkForAllTys, mkTyVarTys, getTyVar_maybe,
splitAlgTyConApp_maybe, instantiateTy, Type
)
import TyCon ( isDataTyCon )
import TyVar ( elementOfTyVarSet, delFromTyVarEnv )
import TyVar ( mkTyVarSet, intersectTyVarSets, elementOfTyVarSet, tyVarSetToList,
delFromTyVarEnv
)
import SrcLoc ( noSrcLoc )
import Util ( isIn, zipWithEqual, panic, assertPanic )
...
...
@@ -182,31 +184,36 @@ mkRhsTyLam [] body = returnSmpl body
mkRhsTyLam tyvars body
= go (\x -> x) body
where
tyvar_
tys
= mkTyVar
Tys
tyvars
main_
tyvar_
set
= mkTyVar
Set
tyvars
go fn (Let bind@(NonRec var rhs) body) | exprIsTrivial rhs
= go (fn . Let bind) body
go fn (Let bind@(NonRec var rhs) body)
= mk_poly var
`thenSmpl` \ (var', rhs') ->
= mk_poly
ty
var
s_here var_ty
`thenSmpl` \ (var', rhs') ->
go (fn . Let (mk_silly_bind var rhs')) body `thenSmpl` \ body' ->
returnSmpl (Let (NonRec var' (mkTyLam tyvars (fn rhs))) body')
returnSmpl (Let (NonRec var' (mkTyLam tyvars_here (fn rhs))) body')
where
tyvars_here = tyVarSetToList (main_tyvar_set `intersectTyVarSets` tyVarsOfType var_ty)
var_ty = idType var
go fn (Let (Rec prs) body)
= mapAndUnzipSmpl mk_poly vars
`thenSmpl` \ (vars', rhss') ->
= mapAndUnzipSmpl
(
mk_poly
ty
vars
_here) var_tys
`thenSmpl` \ (vars', rhss') ->
let
gn body = fn $ foldr Let body (zipWith mk_silly_bind vars rhss')
in
go gn body `thenSmpl` \ body' ->
returnSmpl (Let (Rec (vars' `zip` [mkTyLam tyvars (gn rhs) | rhs <- rhss])) body')
returnSmpl (Let (Rec (vars' `zip` [mkTyLam tyvars
_here
(gn rhs) | rhs <- rhss])) body')
where
(vars,rhss) = unzip prs
tyvars_here = tyVarSetToList (main_tyvar_set `intersectTyVarSets` tyVarsOfTypes var_tys)
var_tys = map idType vars
go fn body = returnSmpl (mkTyLam tyvars (fn body))
mk_poly var
= newId (mkForAllTys tyvars
(idTyp
e var
)
) `thenSmpl` \ poly_id ->
returnSmpl (poly_id, mkTyApp (Var poly_id)
tyvar_tys
)
mk_poly
ty
var
s_here var_ty
= newId (mkForAllTys tyvars
_her
e var
_ty
) `thenSmpl` \ poly_id ->
returnSmpl (poly_id, mkTyApp (Var poly_id)
(mkTyVarTys tyvars_here)
)
mk_silly_bind var rhs = NonRec (addInlinePragma var) rhs
-- The addInlinePragma is really important! If we don't say
...
...
This diff is collapsed.
Click to expand it.
ghc/compiler/typecheck/TcExpr.lhs
+
2
−
6
View file @
ae67eed8
...
...
@@ -36,7 +36,7 @@ import TcEnv ( TcIdOcc(..), tcInstId,
import TcMatches ( tcMatchesCase, tcMatchExpected )
import TcGRHSs ( tcStmt )
import TcMonoType ( tcHsType )
import TcPat ( tcPat )
import TcPat ( tcPat
, badFieldsCon
)
import TcSimplify ( tcSimplifyAndCheck )
import TcType ( TcType, TcTauType, TcMaybe(..),
tcInstType, tcInstSigTcType, tcInstTyVars,
...
...
@@ -457,7 +457,7 @@ tcMonoExpr (RecordCon con_name _ rbinds) res_ty
let
bad_fields = badFields rbinds con_id
in
checkTc (null bad_fields) (badFieldsCon con_
id
bad_fields) `thenTc_`
checkTc (null bad_fields) (badFieldsCon con_
name
bad_fields) `thenTc_`
-- Typecheck the record bindings
-- (Do this after checkRecordFields in case there's a field that
...
...
@@ -1027,10 +1027,6 @@ badFieldsUpd rbinds
recordUpdCtxt = ptext SLIT("In a record update construct")
badFieldsCon con fields
= hsep [ptext SLIT("Constructor"), ppr con,
ptext SLIT("does not have field(s):"), pprQuotedList fields]
notSelector field
= hsep [quotes (ppr field), ptext SLIT("is not a record selector")]
\end{code}
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