Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dylan Yudaken
GHC
Commits
a661df91
Commit
a661df91
authored
Jan 16, 2020
by
Ömer Sinan Ağacan
Committed by
Marge Bot
Jan 20, 2020
Browse files
Document Stg.FVs module
Fixes #17662 [ci skip]
parent
0499e3bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
compiler/GHC/Stg/FVs.hs
View file @
a661df91
-- | Free variable analysis on STG terms.
{- |
Non-global free variable analysis on STG terms. This pass annotates
non-top-level closure bindings with captured variables. Global variables are not
captured. For example, in a top-level binding like (pseudo-STG)
f = \[x,y] .
let g = \[p] . reverse (x ++ p)
in g y
In g, `reverse` and `(++)` are global variables so they're not considered free.
`p` is an argument, so `x` is the only actual free variable here. The annotated
version is thus:
f = \[x,y] .
let g = [x] \[p] . reverse (x ++ p)
in g y
Note that non-top-level recursive bindings are also considered free within the
group:
map = {} \r [f xs0]
let {
Rec {
go = {f, go} \r [xs1]
case xs1 of {
[] -> [] [];
: x xs2 ->
let { xs' = {go, xs2} \u [] go xs2; } in
let { x' = {f, x} \u [] f x; } in
: [x' xs'];
};
end Rec }
} in go xs0;
Here go is free in its RHS.
Top-level closure bindings never capture variables as all of their free
variables are global.
-}
module
GHC.Stg.FVs
(
annTopBindingsFreeVars
,
annBindingFreeVars
...
...
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