Create a deterministic version of tyVarsOfType
[ghc.git] / compiler / coreSyn / CoreFVs.hs
1 {-
2 (c) The University of Glasgow 2006
3 (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4
5 Taken quite directly from the Peyton Jones/Lester paper.
6 -}
7
8 {-# LANGUAGE CPP #-}
9
10 -- | A module concerned with finding the free variables of an expression.
11 module CoreFVs (
12 -- * Free variables of expressions and binding groups
13 exprFreeVars, -- CoreExpr -> VarSet -- Find all locally-defined free Ids or tyvars
14 exprFreeDVars, -- CoreExpr -> DVarSet -- Find all locally-defined free Ids or tyvars
15 exprFreeIds, -- CoreExpr -> IdSet -- Find all locally-defined free Ids
16 exprsFreeVars, -- [CoreExpr] -> VarSet
17 bindFreeVars, -- CoreBind -> VarSet
18
19 -- * Selective free variables of expressions
20 InterestingVarFun,
21 exprSomeFreeVars, exprsSomeFreeVars,
22
23 -- * Free variables of Rules, Vars and Ids
24 varTypeTyVars,
25 idUnfoldingVars, idFreeVars, idRuleAndUnfoldingVars,
26 idFreeVarsAcc,
27 idRuleVars, idRuleRhsVars, stableUnfoldingVars,
28 ruleRhsFreeVars, ruleFreeVars, rulesFreeVars,
29 rulesFreeDVars,
30 ruleLhsFreeIds, exprsOrphNames,
31 vectsFreeVars,
32
33 expr_fvs,
34
35 -- * Core syntax tree annotation with free variables
36 CoreExprWithFVs, -- = AnnExpr Id DVarSet
37 CoreBindWithFVs, -- = AnnBind Id DVarSet
38 freeVars, -- CoreExpr -> CoreExprWithFVs
39 freeVarsOf -- CoreExprWithFVs -> DIdSet
40 ) where
41
42 #include "HsVersions.h"
43
44 import CoreSyn
45 import Id
46 import IdInfo
47 import NameSet
48 import UniqFM
49 import Name
50 import VarSet
51 import Var
52 import TcType
53 import TypeRep
54 import Coercion
55 import Maybes( orElse )
56 import Util
57 import BasicTypes( Activation )
58 import Outputable
59 import FV
60
61 {-
62 ************************************************************************
63 * *
64 \section{Finding the free variables of an expression}
65 * *
66 ************************************************************************
67
68 This function simply finds the free variables of an expression.
69 So far as type variables are concerned, it only finds tyvars that are
70
71 * free in type arguments,
72 * free in the type of a binder,
73
74 but not those that are free in the type of variable occurrence.
75 -}
76
77 -- | Find all locally-defined free Ids or type variables in an expression
78 exprFreeVars :: CoreExpr -> VarSet
79 exprFreeVars = runFVSet . filterFV isLocalVar . expr_fvs
80
81 exprFreeDVars :: CoreExpr -> DVarSet
82 exprFreeDVars = runFVDSet . filterFV isLocalVar . expr_fvs
83
84
85 -- | Find all locally-defined free Ids in an expression
86 exprFreeIds :: CoreExpr -> IdSet -- Find all locally-defined free Ids
87 exprFreeIds = exprSomeFreeVars isLocalId
88
89 -- | Find all locally-defined free Ids or type variables in several expressions
90 exprsFreeVars :: [CoreExpr] -> VarSet
91 exprsFreeVars = mapUnionVarSet exprFreeVars
92
93 -- | Find all locally defined free Ids in a binding group
94 bindFreeVars :: CoreBind -> VarSet
95 bindFreeVars (NonRec b r) = runFVSet $ filterFV isLocalVar $ rhs_fvs (b,r)
96 bindFreeVars (Rec prs) = runFVSet $ filterFV isLocalVar $
97 addBndrs (map fst prs)
98 (foldr (unionFV . rhs_fvs) noVars prs)
99
100 -- | Finds free variables in an expression selected by a predicate
101 exprSomeFreeVars :: InterestingVarFun -- ^ Says which 'Var's are interesting
102 -> CoreExpr
103 -> VarSet
104 exprSomeFreeVars fv_cand e = runFVSet $ filterFV fv_cand $ expr_fvs e
105
106 -- | Finds free variables in several expressions selected by a predicate
107 exprsSomeFreeVars :: InterestingVarFun -- Says which 'Var's are interesting
108 -> [CoreExpr]
109 -> VarSet
110 exprsSomeFreeVars fv_cand es =
111 runFVSet $ filterFV fv_cand $ foldr (unionFV . expr_fvs) noVars es
112
113 -- Comment about obselete code
114 -- We used to gather the free variables the RULES at a variable occurrence
115 -- with the following cryptic comment:
116 -- "At a variable occurrence, add in any free variables of its rule rhss
117 -- Curiously, we gather the Id's free *type* variables from its binding
118 -- site, but its free *rule-rhs* variables from its usage sites. This
119 -- is a little weird. The reason is that the former is more efficient,
120 -- but the latter is more fine grained, and a makes a difference when
121 -- a variable mentions itself one of its own rule RHSs"
122 -- Not only is this "weird", but it's also pretty bad because it can make
123 -- a function seem more recursive than it is. Suppose
124 -- f = ...g...
125 -- g = ...
126 -- RULE g x = ...f...
127 -- Then f is not mentioned in its own RHS, and needn't be a loop breaker
128 -- (though g may be). But if we collect the rule fvs from g's occurrence,
129 -- it looks as if f mentions itself. (This bites in the eftInt/eftIntFB
130 -- code in GHC.Enum.)
131 --
132 -- Anyway, it seems plain wrong. The RULE is like an extra RHS for the
133 -- function, so its free variables belong at the definition site.
134 --
135 -- Deleted code looked like
136 -- foldVarSet add_rule_var var_itself_set (idRuleVars var)
137 -- add_rule_var var set | keep_it fv_cand in_scope var = extendVarSet set var
138 -- | otherwise = set
139 -- SLPJ Feb06
140
141 -- XXX move to FV
142 someVars :: [Var] -> FV
143 someVars vars = foldr (unionFV . oneVar) noVars vars
144
145
146 addBndr :: CoreBndr -> FV -> FV
147 addBndr bndr fv fv_cand in_scope acc
148 = (varTypeTyVarsAcc bndr `unionFV`
149 -- Include type varibles in the binder's type
150 -- (not just Ids; coercion variables too!)
151 FV.delFV bndr fv) fv_cand in_scope acc
152
153 addBndrs :: [CoreBndr] -> FV -> FV
154 addBndrs bndrs fv = foldr addBndr fv bndrs
155
156 expr_fvs :: CoreExpr -> FV
157
158 expr_fvs (Type ty) fv_cand in_scope acc =
159 tyVarsOfTypeAcc ty fv_cand in_scope acc
160 expr_fvs (Coercion co) fv_cand in_scope acc =
161 tyCoVarsOfCoAcc co fv_cand in_scope acc
162 expr_fvs (Var var) fv_cand in_scope acc = oneVar var fv_cand in_scope acc
163 expr_fvs (Lit _) fv_cand in_scope acc = noVars fv_cand in_scope acc
164 expr_fvs (Tick t expr) fv_cand in_scope acc =
165 (tickish_fvs t `unionFV` expr_fvs expr) fv_cand in_scope acc
166 expr_fvs (App fun arg) fv_cand in_scope acc =
167 (expr_fvs fun `unionFV` expr_fvs arg) fv_cand in_scope acc
168 expr_fvs (Lam bndr body) fv_cand in_scope acc =
169 addBndr bndr (expr_fvs body) fv_cand in_scope acc
170 expr_fvs (Cast expr co) fv_cand in_scope acc =
171 (expr_fvs expr `unionFV` tyCoVarsOfCoAcc co) fv_cand in_scope acc
172
173 expr_fvs (Case scrut bndr ty alts) fv_cand in_scope acc
174 = (expr_fvs scrut `unionFV` tyVarsOfTypeAcc ty `unionFV` addBndr bndr
175 (foldr (unionFV . alt_fvs) noVars alts)) fv_cand in_scope acc
176 where
177 alt_fvs (_, bndrs, rhs) = addBndrs bndrs (expr_fvs rhs)
178
179 expr_fvs (Let (NonRec bndr rhs) body) fv_cand in_scope acc
180 = (rhs_fvs (bndr, rhs) `unionFV` addBndr bndr (expr_fvs body))
181 fv_cand in_scope acc
182
183 expr_fvs (Let (Rec pairs) body) fv_cand in_scope acc
184 = addBndrs (map fst pairs)
185 (foldr (unionFV . rhs_fvs) (expr_fvs body) pairs)
186 fv_cand in_scope acc
187
188 ---------
189 rhs_fvs :: (Id, CoreExpr) -> FV
190 rhs_fvs (bndr, rhs) = expr_fvs rhs `unionFV`
191 bndrRuleAndUnfoldingVarsAcc bndr -- XXX: FIXME
192 -- Treat any RULES as extra RHSs of the binding
193
194 ---------
195 exprs_fvs :: [CoreExpr] -> FV
196 exprs_fvs exprs = foldr (unionFV . expr_fvs) noVars exprs
197
198 tickish_fvs :: Tickish Id -> FV
199 tickish_fvs (Breakpoint _ ids) = someVars ids
200 tickish_fvs _ = noVars
201
202 {-
203 ************************************************************************
204 * *
205 \section{Free names}
206 * *
207 ************************************************************************
208 -}
209
210 -- | Finds the free /external/ names of an expression, notably
211 -- including the names of type constructors (which of course do not show
212 -- up in 'exprFreeVars').
213 exprOrphNames :: CoreExpr -> NameSet
214 -- There's no need to delete local binders, because they will all
215 -- be /internal/ names.
216 exprOrphNames e
217 = go e
218 where
219 go (Var v)
220 | isExternalName n = unitNameSet n
221 | otherwise = emptyNameSet
222 where n = idName v
223 go (Lit _) = emptyNameSet
224 go (Type ty) = orphNamesOfType ty -- Don't need free tyvars
225 go (Coercion co) = orphNamesOfCo co
226 go (App e1 e2) = go e1 `unionNameSet` go e2
227 go (Lam v e) = go e `delFromNameSet` idName v
228 go (Tick _ e) = go e
229 go (Cast e co) = go e `unionNameSet` orphNamesOfCo co
230 go (Let (NonRec _ r) e) = go e `unionNameSet` go r
231 go (Let (Rec prs) e) = exprsOrphNames (map snd prs) `unionNameSet` go e
232 go (Case e _ ty as) = go e `unionNameSet` orphNamesOfType ty
233 `unionNameSet` unionNameSets (map go_alt as)
234
235 go_alt (_,_,r) = go r
236
237 -- | Finds the free /external/ names of several expressions: see 'exprOrphNames' for details
238 exprsOrphNames :: [CoreExpr] -> NameSet
239 exprsOrphNames es = foldr (unionNameSet . exprOrphNames) emptyNameSet es
240
241 {-
242 ************************************************************************
243 * *
244 \section[freevars-everywhere]{Attaching free variables to every sub-expression}
245 * *
246 ************************************************************************
247 -}
248
249 -- | Those variables free in the right hand side of a rule
250 ruleRhsFreeVars :: CoreRule -> VarSet
251 ruleRhsFreeVars (BuiltinRule {}) = noFVs
252 ruleRhsFreeVars (Rule { ru_fn = _, ru_bndrs = bndrs, ru_rhs = rhs })
253 = runFVSet $ filterFV isLocalVar $ addBndrs bndrs (expr_fvs rhs)
254 -- See Note [Rule free var hack]
255
256 -- | Those variables free in the both the left right hand sides of a rule
257 ruleFreeVars :: CoreRule -> VarSet
258 ruleFreeVars (BuiltinRule {}) = noFVs
259 ruleFreeVars (Rule { ru_fn = _do_not_include -- See Note [Rule free var hack]
260 , ru_bndrs = bndrs
261 , ru_rhs = rhs, ru_args = args })
262 = runFVSet $ filterFV isLocalVar $ addBndrs bndrs (exprs_fvs (rhs:args))
263
264 ruleFreeVarsAcc :: CoreRule -> FV
265 ruleFreeVarsAcc (BuiltinRule {}) =
266 noVars
267 ruleFreeVarsAcc (Rule { ru_fn = _do_not_include -- See Note [Rule free var hack]
268 , ru_bndrs = bndrs
269 , ru_rhs = rhs, ru_args = args })
270 = addBndrs bndrs (exprs_fvs (rhs:args))
271
272 rulesFreeVarsAcc :: [CoreRule] -> FV
273 rulesFreeVarsAcc (rule:rules) = ruleFreeVarsAcc rule `unionFV` rulesFreeVarsAcc rules
274 rulesFreeVarsAcc [] = noVars
275
276 rulesFreeDVars :: [CoreRule] -> DVarSet
277 rulesFreeDVars rules = runFVDSet $ filterFV isLocalVar $ rulesFreeVarsAcc rules
278
279
280 idRuleRhsVars :: (Activation -> Bool) -> Id -> VarSet
281 -- Just the variables free on the *rhs* of a rule
282 idRuleRhsVars is_active id
283 = mapUnionVarSet get_fvs (idCoreRules id)
284 where
285 get_fvs (Rule { ru_fn = fn, ru_bndrs = bndrs
286 , ru_rhs = rhs, ru_act = act })
287 | is_active act
288 -- See Note [Finding rule RHS free vars] in OccAnal.hs
289 = delFromUFM fvs fn -- Note [Rule free var hack]
290 where
291 fvs = runFVSet $ filterFV isLocalVar $ addBndrs bndrs (expr_fvs rhs)
292 get_fvs _ = noFVs
293
294 -- | Those variables free in the right hand side of several rules
295 rulesFreeVars :: [CoreRule] -> VarSet
296 rulesFreeVars rules = mapUnionVarSet ruleFreeVars rules
297
298 ruleLhsFreeIds :: CoreRule -> VarSet
299 -- ^ This finds all locally-defined free Ids on the left hand side of a rule
300 ruleLhsFreeIds (BuiltinRule {}) = noFVs
301 ruleLhsFreeIds (Rule { ru_bndrs = bndrs, ru_args = args })
302 = runFVSet $ filterFV isLocalId $ addBndrs bndrs (exprs_fvs args)
303
304 {-
305 Note [Rule free var hack] (Not a hack any more)
306 ~~~~~~~~~~~~~~~~~~~~~~~~~
307 We used not to include the Id in its own rhs free-var set.
308 Otherwise the occurrence analyser makes bindings recursive:
309 f x y = x+y
310 RULE: f (f x y) z ==> f x (f y z)
311 However, the occurrence analyser distinguishes "non-rule loop breakers"
312 from "rule-only loop breakers" (see BasicTypes.OccInfo). So it will
313 put this 'f' in a Rec block, but will mark the binding as a non-rule loop
314 breaker, which is perfectly inlinable.
315 -}
316
317 -- |Free variables of a vectorisation declaration
318 vectsFreeVars :: [CoreVect] -> VarSet
319 vectsFreeVars = mapUnionVarSet vectFreeVars
320 where
321 vectFreeVars (Vect _ rhs) = runFVSet $ filterFV isLocalId $ expr_fvs rhs
322 vectFreeVars (NoVect _) = noFVs
323 vectFreeVars (VectType _ _ _) = noFVs
324 vectFreeVars (VectClass _) = noFVs
325 vectFreeVars (VectInst _) = noFVs
326 -- this function is only concerned with values, not types
327
328 {-
329 ************************************************************************
330 * *
331 \section[freevars-everywhere]{Attaching free variables to every sub-expression}
332 * *
333 ************************************************************************
334
335 The free variable pass annotates every node in the expression with its
336 NON-GLOBAL free variables and type variables.
337 -}
338
339 -- | Every node in a binding group annotated with its
340 -- (non-global) free variables, both Ids and TyVars
341 type CoreBindWithFVs = AnnBind Id DVarSet
342 -- | Every node in an expression annotated with its
343 -- (non-global) free variables, both Ids and TyVars
344 type CoreExprWithFVs = AnnExpr Id DVarSet
345
346 freeVarsOf :: CoreExprWithFVs -> DIdSet
347 -- ^ Inverse function to 'freeVars'
348 freeVarsOf (free_vars, _) = free_vars
349
350 noFVs :: VarSet
351 noFVs = emptyVarSet
352
353 aFreeVar :: Var -> DVarSet
354 aFreeVar = unitDVarSet
355
356 unionFVs :: DVarSet -> DVarSet -> DVarSet
357 unionFVs = unionDVarSet
358
359 delBindersFV :: [Var] -> DVarSet -> DVarSet
360 delBindersFV bs fvs = foldr delBinderFV fvs bs
361
362 delBinderFV :: Var -> DVarSet -> DVarSet
363 -- This way round, so we can do it multiple times using foldr
364
365 -- (b `delBinderFV` s) removes the binder b from the free variable set s,
366 -- but *adds* to s
367 --
368 -- the free variables of b's type
369 --
370 -- This is really important for some lambdas:
371 -- In (\x::a -> x) the only mention of "a" is in the binder.
372 --
373 -- Also in
374 -- let x::a = b in ...
375 -- we should really note that "a" is free in this expression.
376 -- It'll be pinned inside the /\a by the binding for b, but
377 -- it seems cleaner to make sure that a is in the free-var set
378 -- when it is mentioned.
379 --
380 -- This also shows up in recursive bindings. Consider:
381 -- /\a -> letrec x::a = x in E
382 -- Now, there are no explicit free type variables in the RHS of x,
383 -- but nevertheless "a" is free in its definition. So we add in
384 -- the free tyvars of the types of the binders, and include these in the
385 -- free vars of the group, attached to the top level of each RHS.
386 --
387 -- This actually happened in the defn of errorIO in IOBase.hs:
388 -- errorIO (ST io) = case (errorIO# io) of
389 -- _ -> bottom
390 -- where
391 -- bottom = bottom -- Never evaluated
392
393 delBinderFV b s = (s `delDVarSet` b) `unionFVs` dVarTypeTyVars b
394 -- Include coercion variables too!
395
396 varTypeTyVars :: Var -> TyVarSet
397 -- Find the type/kind variables free in the type of the id/tyvar
398 varTypeTyVars var = runFVSet $ varTypeTyVarsAcc var
399
400 dVarTypeTyVars :: Var -> DTyVarSet
401 -- Find the type/kind variables free in the type of the id/tyvar
402 dVarTypeTyVars var = runFVDSet $ varTypeTyVarsAcc var
403
404 varTypeTyVarsAcc :: Var -> FV
405 varTypeTyVarsAcc var = tyVarsOfTypeAcc (varType var)
406
407 idFreeVars :: Id -> VarSet
408 idFreeVars id = ASSERT( isId id) runFVSet $ idFreeVarsAcc id
409
410 idFreeVarsAcc :: Id -> FV
411 -- Type variables, rule variables, and inline variables
412 idFreeVarsAcc id = ASSERT( isId id)
413 varTypeTyVarsAcc id `unionFV`
414 idRuleAndUnfoldingVarsAcc id
415
416 bndrRuleAndUnfoldingVarsAcc :: Var -> FV
417 bndrRuleAndUnfoldingVarsAcc v | isTyVar v = noVars
418 | otherwise = idRuleAndUnfoldingVarsAcc v
419
420 idRuleAndUnfoldingVars :: Id -> VarSet
421 idRuleAndUnfoldingVars id = runFVSet $ idRuleAndUnfoldingVarsAcc id
422
423 idRuleAndUnfoldingVarsAcc :: Id -> FV
424 idRuleAndUnfoldingVarsAcc id = ASSERT( isId id)
425 idRuleVarsAcc id `unionFV` idUnfoldingVarsAcc id
426
427
428 idRuleVars ::Id -> VarSet -- Does *not* include CoreUnfolding vars
429 idRuleVars id = runFVSet $ idRuleVarsAcc id
430
431 idRuleVarsAcc :: Id -> FV
432 idRuleVarsAcc id = ASSERT( isId id)
433 someVars (dVarSetElems $ ruleInfoFreeVars (idSpecialisation id))
434
435 idUnfoldingVars :: Id -> VarSet
436 -- Produce free vars for an unfolding, but NOT for an ordinary
437 -- (non-inline) unfolding, since it is a dup of the rhs
438 -- and we'll get exponential behaviour if we look at both unf and rhs!
439 -- But do look at the *real* unfolding, even for loop breakers, else
440 -- we might get out-of-scope variables
441 idUnfoldingVars id = runFVSet $ idUnfoldingVarsAcc id
442
443 idUnfoldingVarsAcc :: Id -> FV
444 idUnfoldingVarsAcc id = stableUnfoldingVarsAcc (realIdUnfolding id) `orElse` noVars
445
446 stableUnfoldingVars :: Unfolding -> Maybe VarSet
447 stableUnfoldingVars unf = runFVSet `fmap` stableUnfoldingVarsAcc unf
448
449 stableUnfoldingVarsAcc :: Unfolding -> Maybe FV
450 stableUnfoldingVarsAcc unf
451 = case unf of
452 CoreUnfolding { uf_tmpl = rhs, uf_src = src }
453 | isStableSource src
454 -> Just (filterFV isLocalVar $ expr_fvs rhs)
455 DFunUnfolding { df_bndrs = bndrs, df_args = args }
456 -> Just (filterFV isLocalVar $ FV.delFVs (mkVarSet bndrs) $ exprs_fvs args)
457 -- DFuns are top level, so no fvs from types of bndrs
458 _other -> Nothing
459
460
461 {-
462 ************************************************************************
463 * *
464 \subsection{Free variables (and types)}
465 * *
466 ************************************************************************
467 -}
468
469 freeVars :: CoreExpr -> CoreExprWithFVs
470 -- ^ Annotate a 'CoreExpr' with its (non-global) free type and value variables at every tree node
471 freeVars (Var v)
472 = (fvs, AnnVar v)
473 where
474 -- ToDo: insert motivating example for why we *need*
475 -- to include the idSpecVars in the FV list.
476 -- Actually [June 98] I don't think it's necessary
477 -- fvs = fvs_v `unionVarSet` idSpecVars v
478
479 fvs | isLocalVar v = aFreeVar v
480 | otherwise = emptyDVarSet
481
482 freeVars (Lit lit) = (emptyDVarSet, AnnLit lit)
483 freeVars (Lam b body)
484 = (b `delBinderFV` freeVarsOf body', AnnLam b body')
485 where
486 body' = freeVars body
487
488 freeVars (App fun arg)
489 = (freeVarsOf fun2 `unionFVs` freeVarsOf arg2, AnnApp fun2 arg2)
490 where
491 fun2 = freeVars fun
492 arg2 = freeVars arg
493
494 freeVars (Case scrut bndr ty alts)
495 = ((bndr `delBinderFV` alts_fvs) `unionFVs` freeVarsOf scrut2 `unionFVs` runFVDSet (tyVarsOfTypeAcc ty),
496 AnnCase scrut2 bndr ty alts2)
497 where
498 scrut2 = freeVars scrut
499
500 (alts_fvs_s, alts2) = mapAndUnzip fv_alt alts
501 alts_fvs = foldr unionFVs emptyDVarSet alts_fvs_s
502
503 fv_alt (con,args,rhs) = (delBindersFV args (freeVarsOf rhs2),
504 (con, args, rhs2))
505 where
506 rhs2 = freeVars rhs
507
508 freeVars (Let (NonRec binder rhs) body)
509 = (freeVarsOf rhs2
510 `unionFVs` body_fvs
511 `unionFVs` runFVDSet (bndrRuleAndUnfoldingVarsAcc binder),
512 -- Remember any rules; cf rhs_fvs above
513 AnnLet (AnnNonRec binder rhs2) body2)
514 where
515 rhs2 = freeVars rhs
516 body2 = freeVars body
517 body_fvs = binder `delBinderFV` freeVarsOf body2
518
519 freeVars (Let (Rec binds) body)
520 = (delBindersFV binders all_fvs,
521 AnnLet (AnnRec (binders `zip` rhss2)) body2)
522 where
523 (binders, rhss) = unzip binds
524
525 rhss2 = map freeVars rhss
526 rhs_body_fvs = foldr (unionFVs . freeVarsOf) body_fvs rhss2
527 binders_fvs = runFVDSet $ foldr (unionFV . idRuleAndUnfoldingVarsAcc) noVars binders
528 all_fvs = rhs_body_fvs `unionFVs` binders_fvs
529 -- The "delBinderFV" happens after adding the idSpecVars,
530 -- since the latter may add some of the binders as fvs
531
532 body2 = freeVars body
533 body_fvs = freeVarsOf body2
534
535 freeVars (Cast expr co)
536 = (freeVarsOf expr2 `unionFVs` cfvs, AnnCast expr2 (cfvs, co))
537 where
538 expr2 = freeVars expr
539 cfvs = runFVDSet $ tyCoVarsOfCoAcc co
540
541 freeVars (Tick tickish expr)
542 = (tickishFVs tickish `unionFVs` freeVarsOf expr2, AnnTick tickish expr2)
543 where
544 expr2 = freeVars expr
545 tickishFVs (Breakpoint _ ids) = mkDVarSet ids
546 tickishFVs _ = emptyDVarSet
547
548 freeVars (Type ty) = (runFVDSet $ tyVarsOfTypeAcc ty, AnnType ty)
549
550 freeVars (Coercion co) = (runFVDSet $ tyCoVarsOfCoAcc co, AnnCoercion co)