[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / compiler / abstractSyn / AbsSynFuns.lhs
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1995
3 %
4 \section[AbsSynFuns]{Abstract syntax: help functions}
5
6 \begin{code}
7 #include "HsVersions.h"
8
9 module AbsSynFuns (
10         collectTopLevelBinders,
11         collectBinders, collectTypedBinders,
12         collectMonoBinders,
13         collectMonoBindersAndLocs,
14         collectPatBinders,
15         collectQualBinders,
16         collectTypedPatBinders,
17 #ifdef DPH
18         collectParQualBinders,
19 #endif {- Data Parallel Haskell -}
20         cmpInstanceTypes,
21         extractMonoTyNames,
22 {-OLD:-}getMentionedVars, -- MENTIONED
23         getNonPrelOuterTyCon,
24         mkDictApp,
25         mkDictLam,
26         mkTyApp,
27         mkTyLam,
28
29         PreludeNameFun(..)
30     ) where
31
32 IMPORT_Trace
33
34 import AbsSyn
35
36 import HsTypes          ( cmpMonoType )
37 import Id               ( Id, DictVar(..), DictFun(..) )
38 import Maybes           ( Maybe(..) )
39 import ProtoName        ( ProtoName(..), cmpProtoName )
40 import Rename           ( PreludeNameFun(..) )
41 import Util
42 \end{code}
43
44 %************************************************************************
45 %*                                                                      *
46 \subsection[AbsSynFuns-MonoBinds]{Bindings: @MonoBinds@}
47 %*                                                                      *
48 %************************************************************************
49
50 Get all the binders in some @ProtoNameMonoBinds@, IN THE ORDER OF
51 APPEARANCE; e.g., in:
52 \begin{verbatim}
53 ...
54 where
55   (x, y) = ...
56   f i j  = ...
57   [a, b] = ...
58 \end{verbatim}
59 it should return @[x, y, f, a, b]@ (remember, order important).
60
61 \begin{code}
62 collectTopLevelBinders :: Binds name (InPat name) -> [name]
63 collectTopLevelBinders EmptyBinds     = []
64 collectTopLevelBinders (SingleBind b) = collectBinders b
65 collectTopLevelBinders (BindWith b _) = collectBinders b
66 collectTopLevelBinders (ThenBinds b1 b2) 
67  = (collectTopLevelBinders b1) ++ (collectTopLevelBinders b2)
68
69 {- --------- DO THIS WHEN VarMonoBind binds a "name" rather than a "Id"
70
71 collectBinders :: Bind name (InPat name) -> [name]
72 collectBinders = collectGenericBinders collectPatBinders
73 collectTypedBinders :: TypecheckedBind -> TypecheckedPat -> [name]
74 collectTypedBinders = collectGenericBinders collectTypedPatBinders
75
76 collectGenericBinders :: (pat -> [name]) -> Bind name pat -> [name]
77 collectGenericBinders pat_fn EmptyBind = []
78 collectGenericBinders pat_fn (NonRecBind monobinds)     
79  = collectGenericMonoBinders pat_fn monobinds
80 collectGenericBinders pat_fn (RecBind monobinds)        
81  = collectGenericMonoBinders pat_fn monobinds
82
83 collectMonoBinders :: MonoBinds name (InPat name) -> [name]
84 collectMonoBinders = collectGenericMonoBinders collectPatBinders
85
86
87 collectGenericMonoBinders :: (pat -> [name]) -> MonoBinds name pat -> [name]
88 collectGenericMonoBinders pat_fn EmptyMonoBinds = []
89 collectGenericMonoBinders pat_fn (AndMonoBinds bs1 bs2)
90  = (collectGenericMonoBinders pat_fn bs1) ++ (collectGenericMonoBinders pat_fn bs2)
91 collectGenericMonoBinders pat_fn (PatMonoBind pat grhss_w_binds locn) 
92  = pat_fn pat
93 collectGenericMonoBinders pat_fn (FunMonoBind f matches locn) = [f]
94 collectGenericMonoBinders pat_fn (VarMonoBind v expr) = [v]
95
96 ------------------ -}
97
98 -- ------- UNTIL THEN, WE DUPLICATE CODE -----------}
99
100 collectBinders :: Bind name (InPat name) -> [name]
101 collectBinders EmptyBind              = []
102 collectBinders (NonRecBind monobinds) = collectMonoBinders monobinds
103 collectBinders (RecBind monobinds)    = collectMonoBinders monobinds
104
105 collectTypedBinders :: TypecheckedBind -> [Id]
106 collectTypedBinders EmptyBind         = []
107 collectTypedBinders (NonRecBind monobinds) = collectTypedMonoBinders monobinds
108 collectTypedBinders (RecBind monobinds)    = collectTypedMonoBinders monobinds
109
110 collectMonoBinders :: MonoBinds name (InPat name) -> [name]
111 collectMonoBinders EmptyMonoBinds                    = []
112 collectMonoBinders (PatMonoBind pat grhss_w_binds _) = collectPatBinders pat
113 collectMonoBinders (FunMonoBind f matches _)         = [f]
114 collectMonoBinders (VarMonoBind v expr)              = error "collectMonoBinders"
115 collectMonoBinders (AndMonoBinds bs1 bs2)
116  = (collectMonoBinders bs1) ++ (collectMonoBinders bs2)
117
118 collectTypedMonoBinders :: TypecheckedMonoBinds -> [Id]
119 collectTypedMonoBinders EmptyMonoBinds                    = []
120 collectTypedMonoBinders (PatMonoBind pat grhss_w_binds _) = collectTypedPatBinders pat
121 collectTypedMonoBinders (FunMonoBind f matches _)         = [f]
122 collectTypedMonoBinders (VarMonoBind v expr)              = [v]
123 collectTypedMonoBinders (AndMonoBinds bs1 bs2)
124  = (collectTypedMonoBinders bs1) ++ (collectTypedMonoBinders bs2)
125
126 -- ---------- END OF DUPLICATED CODE
127
128 -- We'd like the binders -- and where they came from --
129 -- so we can make new ones with equally-useful origin info.
130
131 collectMonoBindersAndLocs
132         :: MonoBinds name (InPat name) -> [(name, SrcLoc)]
133
134 collectMonoBindersAndLocs EmptyMonoBinds = []
135
136 collectMonoBindersAndLocs (AndMonoBinds bs1 bs2)
137   = collectMonoBindersAndLocs bs1 ++ collectMonoBindersAndLocs bs2
138
139 collectMonoBindersAndLocs (PatMonoBind pat grhss_w_binds locn) 
140   = collectPatBinders pat `zip` repeat locn
141
142 collectMonoBindersAndLocs (FunMonoBind f matches locn) = [(f, locn)]
143
144 collectMonoBindersAndLocs (VarMonoBind v expr)
145   = trace "collectMonoBindersAndLocs:VarMonoBind" []
146         -- ToDo: this is dubious, i.e., wrong, but harmless?
147 \end{code}
148
149 %************************************************************************
150 %*                                                                      *
151 \subsection[AbsSynFuns-Expr]{Help functions: @Expr@}
152 %*                                                                      *
153 %************************************************************************
154
155 And some little help functions that remove redundant redundancy:
156 \begin{code}
157 mkTyApp :: TypecheckedExpr -> [UniType] -> TypecheckedExpr
158 mkTyApp expr []  = expr
159 mkTyApp expr tys = TyApp expr tys
160
161 mkDictApp :: TypecheckedExpr -> [DictVar] -> TypecheckedExpr
162 mkDictApp expr []         = expr
163 mkDictApp expr dict_vars = DictApp expr dict_vars
164
165 mkTyLam :: [TyVar] -> TypecheckedExpr -> TypecheckedExpr
166 mkTyLam []     expr = expr
167 mkTyLam tyvars expr = TyLam tyvars expr
168
169 mkDictLam :: [DictVar] -> TypecheckedExpr -> TypecheckedExpr
170 mkDictLam [] expr = expr
171 mkDictLam dicts expr = DictLam dicts expr
172 \end{code}
173
174 %************************************************************************
175 %*                                                                      *
176 \subsection[AbsSynFuns-Qual]{Help functions: @Quals@}
177 %*                                                                      *
178 %************************************************************************
179
180 \begin{code}
181 #ifdef DPH
182 collectParQualBinders :: RenamedParQuals -> [Name]
183 collectParQualBinders (AndParQuals q1 q2) 
184    = collectParQualBinders q1 ++ collectParQualBinders q2
185
186 collectParQualBinders (DrawnGenIn pats pat expr) 
187    = concat ((map collectPatBinders pats)++[collectPatBinders pat])
188
189 collectParQualBinders (IndexGen exprs pat expr) 
190    = (collectPatBinders pat)
191
192 collectParQualBinders (ParFilter expr) = []
193 #endif {- Data Parallel HAskell -}
194 \end{code}
195
196 %************************************************************************
197 %*                                                                      *
198 \subsection[AbsSynFuns-ParQuals]{Help functions: @ParQuals@}
199 %*                                                                      *
200 %************************************************************************
201
202 \begin{code}
203 collectQualBinders :: [RenamedQual] -> [Name]
204
205 collectQualBinders quals
206   = concat (map collect quals)
207   where
208     collect (GeneratorQual pat expr) = collectPatBinders pat
209     collect (FilterQual expr) = []
210 \end{code}
211
212 %************************************************************************
213 %*                                                                      *
214 \subsection[AbsSynFuns-pats]{Help functions: patterns}
215 %*                                                                      *
216 %************************************************************************
217
218 With un-parameterised patterns, we have to have ``duplicate'' copies
219 of one or two functions:
220 \begin{code}
221 collectPatBinders :: InPat a -> [a]
222 collectPatBinders (VarPatIn var)            = [var]
223 collectPatBinders (LazyPatIn pat)    = collectPatBinders pat
224 collectPatBinders (AsPatIn a pat)    = a : (collectPatBinders pat)
225 collectPatBinders (ConPatIn c pats)  = concat (map collectPatBinders pats)
226 collectPatBinders (ConOpPatIn p1 c p2)= (collectPatBinders p1) ++ (collectPatBinders p2)
227 collectPatBinders (ListPatIn pats)   = concat (map collectPatBinders pats)
228 collectPatBinders (TuplePatIn pats)  = concat (map collectPatBinders pats)
229 collectPatBinders (NPlusKPatIn n _)  = [n]
230 #ifdef DPH
231 collectPatBinders (ProcessorPatIn pats pat)
232    = concat (map collectPatBinders pats) ++ (collectPatBinders pat)
233 #endif
234 collectPatBinders any_other_pat     = [ {-no binders-} ]
235 \end{code}
236
237 Nota bene: DsBinds relies on the fact that at least for simple
238 tuple patterns @collectTypedPatBinders@ returns the binders in 
239 the same order as they appear in the tuple.
240
241 \begin{code}
242 collectTypedPatBinders :: TypecheckedPat -> [Id]
243 collectTypedPatBinders (VarPat var)         = [var]
244 collectTypedPatBinders (LazyPat pat)        = collectTypedPatBinders pat
245 collectTypedPatBinders (AsPat a pat)        = a : (collectTypedPatBinders pat)
246 collectTypedPatBinders (ConPat _ _ pats)    = concat (map collectTypedPatBinders pats)
247 collectTypedPatBinders (ConOpPat p1 _ p2 _) = (collectTypedPatBinders p1) ++ (collectTypedPatBinders p2)
248 collectTypedPatBinders (ListPat t pats)    = concat (map collectTypedPatBinders pats)
249 collectTypedPatBinders (TuplePat pats)      = concat (map collectTypedPatBinders pats)
250 collectTypedPatBinders (NPlusKPat n _ _ _ _ _) = [n]
251 #ifdef DPH
252 collectTypedPatBinders (ProcessorPat pats _ pat) 
253   = (concat (map collectTypedPatBinders pats)) ++ 
254     (collectTypedPatBinders pat)
255 #endif {- Data Parallel Haskell -}
256 collectTypedPatBinders any_other_pat        = [ {-no binders-} ]
257 \end{code}
258
259 %************************************************************************
260 %*                                                                      *
261 \subsection[AbsSynFuns-MonoType]{Help functions: @MonoType@}
262 %*                                                                      *
263 %************************************************************************
264
265 Get the type variable names from a @MonoType@.  Don't use class @Eq@
266 because @ProtoNames@ aren't in it.
267
268 \begin{code}
269 extractMonoTyNames :: (name -> name -> Bool) -> MonoType name -> [name]
270
271 extractMonoTyNames eq monotype
272   = get monotype []
273   where
274     get (MonoTyVar name) acc | name `is_elem` acc = acc
275                                | otherwise            = name : acc
276     get (MonoTyCon con tys) acc = foldr get acc tys
277     get (ListMonoTy ty)     acc = get ty acc
278     get (FunMonoTy ty1 ty2) acc = get ty1 (get ty2 acc)
279     get (TupleMonoTy tys)   acc
280       = foldr get_poly acc tys
281       where
282         get_poly (UnoverloadedTy ty)    acc = get ty acc
283         get_poly (ForAllTy _ ty)        acc = get ty acc
284         get_poly (OverloadedTy ctxt ty) acc = panic "extractMonoTyNames"
285     get (MonoDict _ ty)     acc = get ty acc
286     get (MonoTyVarTemplate _) acc = acc
287 #ifdef DPH
288     get (MonoTyProc tys ty) acc = foldr get (get ty acc) tys
289     get (MonoTyPod  ty)     acc = get ty acc
290 #endif {- Data Parallel Haskell -}
291
292     is_elem n []     = False
293     is_elem n (x:xs) = n `eq` x || n `is_elem` xs
294 \end{code}
295
296 @cmpInstanceTypes@ compares two @MonoType@s which are being used as
297 ``instance types.''  This is used when comparing as-yet-unrenamed
298 instance decls to eliminate duplicates.  We allow things (e.g.,
299 overlapping instances) which standard Haskell doesn't, so we must
300 cater for that.  Generally speaking, the instance-type
301 ``shape''-checker in @tcInstDecl@ will catch any mischief later on.
302
303 All we do is call @cmpMonoType@, passing it a tyvar-comparing function
304 that always claims that tyvars are ``equal;'' the result is that we
305 end up comparing the non-tyvar-ish structure of the two types.
306
307 \begin{code}
308 cmpInstanceTypes :: ProtoNameMonoType -> ProtoNameMonoType -> TAG_
309
310 cmpInstanceTypes ty1 ty2
311   = cmpMonoType funny_cmp ty1 ty2
312   where
313     funny_cmp :: ProtoName -> ProtoName -> TAG_
314
315     {- The only case we are really trying to catch
316        is when both types are tyvars: which are both
317        "Unk"s and names that start w/ a lower-case letter! (Whew.)
318     -}
319     funny_cmp (Unk u1) (Unk u2)
320       | isLower s1 && isLower s2 = EQ_
321       where
322         s1 = _HEAD_ u1
323         s2 = _HEAD_ u2
324
325     funny_cmp x y = cmpProtoName x y -- otherwise completely normal
326 \end{code}
327
328 @getNonPrelOuterTyCon@ is a yukky function required when deciding
329 whether to import an instance decl.  If the class name or type
330 constructor are ``wanted'' then we should import it, otherwise not.
331 But the built-in core constructors for lists, tuples and arrows are
332 never ``wanted'' in this sense.  @getNonPrelOuterTyCon@ catches just a
333 user-defined tycon and returns it.
334
335 \begin{code}
336 getNonPrelOuterTyCon :: ProtoNameMonoType -> Maybe ProtoName
337
338 getNonPrelOuterTyCon (MonoTyCon con _)   = Just con
339 getNonPrelOuterTyCon _                   = Nothing
340 \end{code}
341
342 %************************************************************************
343 %*                                                                      *
344 \subsection[AbsSynFuns-mentioned-vars]{Collect mentioned variables}
345 %*                                                                      *
346 %************************************************************************
347
348 This is just a {\em hack} whichs collects, from a module body, all the
349 variables that are ``mentioned,'' either as top-level binders or as
350 free variables.  We can then use this list when walking over
351 interfaces, using it to avoid imported variables that are patently of
352 no interest.
353
354 We have to be careful to look out for \tr{M..} constructs in the
355 export list; if so, the game is up (and we must so report).
356
357 \begin{code}
358 {- OLD:MENTIONED-}
359 getMentionedVars :: PreludeNameFun      -- a prelude-name lookup function, so
360                                         -- we can avoid recording prelude things
361                                         -- as "mentioned"
362                  -> [IE]{-exports-}     -- All the bits of the module body to 
363                  -> [ProtoNameFixityDecl]-- look in for "mentioned" vars.
364                  -> [ProtoNameClassDecl]
365                  -> [ProtoNameInstDecl]
366                  -> ProtoNameBinds
367
368                  -> (Bool,              -- True <=> M.. construct in exports
369                      [FAST_STRING])     -- list of vars "mentioned" in the module body
370
371 getMentionedVars val_nf exports fixes class_decls inst_decls binds
372   = case (mention_IE exports) of { (module_dotdot_seen, export_mentioned) ->
373     (module_dotdot_seen,
374      concat [export_mentioned,
375              mention_Fixity            fixes,
376              mention_ClassDecls val_nf class_decls,
377              mention_InstDecls  val_nf inst_decls,
378              mention_Binds      val_nf True{-top-level-} binds])
379     }
380 \end{code}
381
382 \begin{code}
383 mention_IE :: [IE] -> (Bool, [FAST_STRING])
384
385 mention_IE exps
386   = foldr men (False, []) exps
387   where
388     men (IEVar str) (dotdot_seen, so_far) = (dotdot_seen, str : so_far)
389     men (IEModuleContents _)  (_, so_far) = (True, so_far)
390     men other_ie              acc         = acc
391 \end{code}
392
393 \begin{code}
394 mention_Fixity :: [ProtoNameFixityDecl] -> [FAST_STRING]
395
396 mention_Fixity fixity_decls = []
397     -- ToDo: if we ever do something proper with fixity declarations,
398     -- this might need to do something.
399 \end{code}
400
401 \begin{code}
402 mention_ClassDecls :: PreludeNameFun -> [ProtoNameClassDecl] -> [FAST_STRING]
403
404 mention_ClassDecls val_nf [] = []
405 mention_ClassDecls val_nf (ClassDecl _ _ _ _ binds _ _ : rest)
406   = mention_MonoBinds val_nf True{-toplev-} binds
407     ++ mention_ClassDecls val_nf rest
408 \end{code}
409
410 \begin{code}
411 mention_InstDecls :: PreludeNameFun -> [ProtoNameInstDecl] -> [FAST_STRING]
412
413 mention_InstDecls val_nf [] = []
414 mention_InstDecls val_nf (InstDecl _ _ _ binds _ _ _ _ _ _ : rest)
415   = mention_MonoBinds val_nf True{-toplev-} binds
416     ++ mention_InstDecls val_nf rest
417 \end{code}
418
419 \begin{code}
420 mention_Binds :: PreludeNameFun -> Bool -> ProtoNameBinds -> [FAST_STRING]
421
422 mention_Binds val_nf toplev EmptyBinds = []
423 mention_Binds val_nf toplev (ThenBinds a b)
424   = mention_Binds val_nf toplev a ++ mention_Binds val_nf toplev b
425 mention_Binds val_nf toplev (SingleBind a) = mention_Bind val_nf toplev a
426 mention_Binds val_nf toplev (BindWith a _) = mention_Bind val_nf toplev a
427 \end{code}
428
429 \begin{code}
430 mention_Bind :: PreludeNameFun -> Bool -> ProtoNameBind -> [FAST_STRING]
431
432 mention_Bind val_nf toplev EmptyBind        = []
433 mention_Bind val_nf toplev (NonRecBind a)   = mention_MonoBinds val_nf toplev a
434 mention_Bind val_nf toplev (RecBind a)      = mention_MonoBinds val_nf toplev a
435 \end{code}
436
437 \begin{code}
438 mention_MonoBinds :: PreludeNameFun -> Bool -> ProtoNameMonoBinds -> [FAST_STRING]
439
440 mention_MonoBinds val_nf toplev EmptyMonoBinds = []
441 mention_MonoBinds val_nf toplev (AndMonoBinds a b)
442   = mention_MonoBinds val_nf toplev a ++ mention_MonoBinds val_nf toplev b
443 mention_MonoBinds val_nf toplev (PatMonoBind p gb _)
444   = let
445         rest = mention_GRHSsAndBinds val_nf gb
446     in
447     if toplev
448     then (map stringify (collectPatBinders p)) ++ rest
449     else rest
450
451 mention_MonoBinds val_nf toplev (FunMonoBind v ms _)
452   = let
453         rest = concat (map (mention_Match val_nf) ms)
454     in
455     if toplev then (stringify v) : rest else rest
456
457 stringify :: ProtoName -> FAST_STRING
458 stringify (Unk s) = s
459 \end{code}
460
461 \begin{code}
462 mention_Match :: PreludeNameFun -> ProtoNameMatch -> [FAST_STRING]
463
464 mention_Match val_nf (PatMatch _ m) = mention_Match val_nf m
465 mention_Match val_nf (GRHSMatch gb) = mention_GRHSsAndBinds val_nf gb
466 \end{code}
467
468 \begin{code}
469 mention_GRHSsAndBinds :: PreludeNameFun -> ProtoNameGRHSsAndBinds -> [FAST_STRING]
470
471 mention_GRHSsAndBinds val_nf (GRHSsAndBindsIn gs bs)
472   = mention_GRHSs val_nf gs ++ mention_Binds val_nf False bs
473 \end{code}
474
475 \begin{code}
476 mention_GRHSs :: PreludeNameFun -> [ProtoNameGRHS] -> [FAST_STRING]
477
478 mention_GRHSs val_nf grhss
479   = concat (map mention_grhs grhss)
480   where
481     mention_grhs (OtherwiseGRHS e _) = mention_Expr val_nf [] e
482     mention_grhs (GRHS g e _)
483       = mention_Expr val_nf [] g  ++ mention_Expr val_nf [] e
484 \end{code}
485
486 \begin{code}
487 mention_Expr :: PreludeNameFun -> [FAST_STRING] -> ProtoNameExpr -> [FAST_STRING]
488
489 mention_Expr val_nf acc (Var v)
490   = case v of
491       Unk str | _LENGTH_ str >= 3
492         -> case (val_nf str) of
493              Nothing -> str : acc
494              Just _  -> acc
495       other -> acc
496
497 mention_Expr val_nf acc (Lit _) = acc
498 mention_Expr val_nf acc (Lam m) = acc ++ (mention_Match val_nf m)
499 mention_Expr val_nf acc (App a b) = mention_Expr val_nf (mention_Expr val_nf acc a) b
500 mention_Expr val_nf acc (OpApp a b c) = mention_Expr val_nf (mention_Expr val_nf (mention_Expr val_nf acc a) b) c
501 mention_Expr val_nf acc (SectionL a b) = mention_Expr val_nf (mention_Expr val_nf acc a) b
502 mention_Expr val_nf acc (SectionR a b) = mention_Expr val_nf (mention_Expr val_nf acc a) b
503 mention_Expr val_nf acc (CCall _ es _ _ _) = mention_Exprs val_nf acc es
504 mention_Expr val_nf acc (SCC _ e) = mention_Expr val_nf acc e
505 mention_Expr val_nf acc (Case e ms) = mention_Expr val_nf acc e ++ concat (map (mention_Match val_nf) ms)
506 mention_Expr val_nf acc (ListComp e q) = mention_Expr val_nf acc e ++ mention_Quals val_nf q
507 mention_Expr val_nf acc (Let b e) = (mention_Expr val_nf acc e) ++ (mention_Binds val_nf False{-not toplev-} b)
508 mention_Expr val_nf acc (ExplicitList es)  = mention_Exprs val_nf acc es
509 mention_Expr val_nf acc (ExplicitTuple es) = mention_Exprs val_nf acc es
510 mention_Expr val_nf acc (ExprWithTySig e _) = mention_Expr val_nf acc e
511 mention_Expr val_nf acc (If b t e) = mention_Expr val_nf (mention_Expr val_nf (mention_Expr val_nf acc b) t) e
512 mention_Expr val_nf acc (ArithSeqIn s) = mention_ArithSeq val_nf acc s
513 #ifdef DPH
514 mention_Expr val_nf acc (ParallelZF e q) = (mention_Expr val_nf acc e) ++ 
515                                            (mention_ParQuals val_nf q)
516 mention_Expr val_nf acc (ExplicitPodIn es) = mention_Exprs val_nf acc es
517 mention_Expr val_nf acc (ExplicitProcessor es e) = mention_Expr val_nf (mention_Exprs val_nf acc es) e
518 #endif {- Data Parallel Haskell -}
519 \end{code}
520
521 \begin{code}
522 mention_Exprs :: PreludeNameFun -> [FAST_STRING] -> [ProtoNameExpr] -> [FAST_STRING]
523
524 mention_Exprs val_nf acc []     = acc
525 mention_Exprs val_nf acc (e:es) = mention_Exprs val_nf (mention_Expr val_nf acc e) es
526 \end{code}
527
528 \begin{code}
529 mention_ArithSeq :: PreludeNameFun -> [FAST_STRING] -> ProtoNameArithSeqInfo -> [FAST_STRING]
530
531 mention_ArithSeq val_nf acc (From       e1)
532   = mention_Expr val_nf acc e1
533 mention_ArithSeq val_nf acc (FromThen   e1 e2)
534   = mention_Expr val_nf (mention_Expr val_nf acc e1) e2
535 mention_ArithSeq val_nf acc (FromTo     e1 e2)
536   = mention_Expr val_nf (mention_Expr val_nf acc e1) e2
537 mention_ArithSeq val_nf acc (FromThenTo e1 e2 e3)
538   = mention_Expr val_nf (mention_Expr val_nf (mention_Expr val_nf acc e1) e2) e3
539 \end{code}
540
541 \begin{code}
542 mention_Quals :: PreludeNameFun -> [ProtoNameQual] -> [FAST_STRING]
543
544 mention_Quals val_nf quals
545   = concat (map mention quals)
546   where
547     mention (GeneratorQual _ e) = mention_Expr val_nf [] e
548     mention (FilterQual e)      = mention_Expr val_nf [] e
549 \end{code}
550
551 \begin{code}
552 #ifdef DPH
553 mention_ParQuals :: PreludeNameFun -> ProtoNameParQuals -> [FAST_STRING]
554 mention_ParQuals val_nf (ParFilter e)      = mention_Expr val_nf [] e
555 mention_ParQuals val_nf (DrawnGenIn _ _ e) = mention_Expr val_nf [] e
556 mention_ParQuals val_nf (AndParQuals a b)  = mention_ParQuals val_nf a ++ 
557                                              mention_ParQuals val_nf b
558 mention_ParQuals val_nf (IndexGen es _ e)  = mention_Exprs val_nf [] es 
559                                              ++ mention_Expr val_nf [] e
560 #endif {- Data Parallel Haskell -}
561
562 {- END OLD:MENTIONED -}
563 \end{code}