[project @ 2000-03-23 17:45:17 by simonpj]
[ghc-hetmet.git] / ghc / compiler / basicTypes / Name.lhs
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
3 %
4 \section[Name]{@Name@: to transmit name info from renamer to typechecker}
5
6 \begin{code}
7 module Name (
8         -- Re-export the OccName stuff
9         module OccName,
10
11         -- The Name type
12         Name,                                   -- Abstract
13         mkLocalName, mkImportedLocalName, mkSysLocalName, mkCCallName,
14         mkTopName, mkIPName,
15         mkDerivedName, mkGlobalName, mkKnownKeyGlobal,
16         mkWiredInIdName,   mkWiredInTyConName,
17         maybeWiredInIdName, maybeWiredInTyConName,
18         isWiredInName, hashName,
19
20         nameUnique, setNameUnique, setNameProvenance, getNameProvenance, setNameImportReason,
21         tidyTopName, 
22         nameOccName, nameModule, setNameOcc, nameRdrName, setNameModule,
23
24         isUserExportedName, isUserImportedName, isUserImportedExplicitlyName, nameSrcLoc,
25         isLocallyDefinedName, isDynName,
26
27         isSystemName, isLocalName, isGlobalName, isExternallyVisibleName,
28         
29
30         -- Provenance
31         Provenance(..), ImportReason(..), pprProvenance,
32         ExportFlag(..), PrintUnqualified,
33         pprNameProvenance, hasBetterProv,
34
35         -- Class NamedThing and overloaded friends
36         NamedThing(..),
37         getSrcLoc, isLocallyDefined, getOccString
38     ) where
39
40 #include "HsVersions.h"
41
42 import {-# SOURCE #-} Var   ( Id, setIdName )
43 import {-# SOURCE #-} TyCon ( TyCon, setTyConName )
44
45 import OccName          -- All of it
46 import Module           ( Module, moduleName, pprModule, mkVanillaModule, isDynamicModule )
47 import RdrName          ( RdrName, mkRdrQual, mkRdrUnqual, rdrNameOcc, rdrNameModule )
48 import CmdLineOpts      ( opt_PprStyle_NoPrags, opt_OmitInterfacePragmas, opt_EnsureSplittableC )
49
50 import SrcLoc           ( noSrcLoc, mkBuiltinSrcLoc, SrcLoc )
51 import Unique           ( pprUnique, Unique, Uniquable(..), u2i )
52 import Outputable
53 import GlaExts
54 \end{code}
55
56
57 %************************************************************************
58 %*                                                                      *
59 \subsection[Name-datatype]{The @Name@ datatype, and name construction}
60 %*                                                                      *
61 %************************************************************************
62  
63 \begin{code}
64 data Name = Name {
65                 n_sort :: NameSort,     -- What sort of name it is
66                 n_uniq :: Unique,
67                 n_occ  :: OccName,      -- Its occurrence name
68                 n_prov :: Provenance    -- How it was made
69             }
70
71 data NameSort
72   = Local
73   | Global Module
74   | WiredInId Module Id
75   | WiredInTyCon Module TyCon
76 \end{code}
77
78 Things with a @Global@ name are given C static labels, so they finally
79 appear in the .o file's symbol table.  They appear in the symbol table
80 in the form M.n.  If originally-local things have this property they
81 must be made @Global@ first.
82
83 \begin{code}
84 mkLocalName :: Unique -> OccName -> SrcLoc -> Name
85 mkLocalName uniq occ loc = Name { n_uniq = uniq, n_sort = Local, n_occ = occ, 
86                                   n_prov = LocalDef loc NotExported }
87         -- NB: You might worry that after lots of huffing and
88         -- puffing we might end up with two local names with distinct
89         -- uniques, but the same OccName.  Indeed we can, but that's ok
90         --      * the insides of the compiler don't care: they use the Unique
91         --      * when printing for -ddump-xxx you can switch on -dppr-debug to get the
92         --        uniques if you get confused
93         --      * for interface files we tidyCore first, which puts the uniques
94         --        into the print name (see setNameVisibility below)
95
96 mkImportedLocalName :: Unique -> OccName -> SrcLoc -> Name
97         -- Just the same as mkLocalName, except the provenance is different
98         -- Reason: this flags the name as one that came in from an interface file.
99         -- This is useful when trying to decide which of two type variables
100         -- should 'win' when unifying them.
101         -- NB: this is only for non-top-level names, so we use ImplicitImport
102 mkImportedLocalName uniq occ loc = Name { n_uniq = uniq, n_sort = Local, n_occ = occ, 
103                                           n_prov = NonLocalDef ImplicitImport True }
104
105
106 mkGlobalName :: Unique -> Module -> OccName -> Provenance -> Name
107 mkGlobalName uniq mod occ prov = Name { n_uniq = uniq, n_sort = Global mod,
108                                         n_occ = occ, n_prov = prov }
109                                 
110
111 mkKnownKeyGlobal :: (RdrName, Unique) -> Name
112 mkKnownKeyGlobal (rdr_name, uniq)
113   = mkGlobalName uniq (mkVanillaModule (rdrNameModule rdr_name))
114                       (rdrNameOcc rdr_name)
115                       systemProvenance
116
117 mkSysLocalName :: Unique -> UserFS -> Name
118 mkSysLocalName uniq fs = Name { n_uniq = uniq, n_sort = Local, 
119                                 n_occ = mkSrcVarOcc fs, n_prov = systemProvenance }
120
121 mkCCallName :: Unique -> EncodedString -> Name
122         -- The encoded string completely describes the ccall
123 mkCCallName uniq str =  Name { n_uniq = uniq, n_sort = Local, 
124                                n_occ = mkCCallOcc str, 
125                                n_prov = NonLocalDef ImplicitImport True }
126
127 mkTopName :: Unique -> Module -> FAST_STRING -> Name
128         -- Make a top-level name; make it Global if top-level
129         -- things should be externally visible; Local otherwise
130         -- This chap is only used *after* the tidyCore phase
131         -- Notably, it is used during STG lambda lifting
132         --
133         -- We have to make sure that the name is globally unique
134         -- and we don't have tidyCore to help us. So we append
135         -- the unique.  Hack!  Hack!
136 mkTopName uniq mod fs
137   = Name { n_uniq = uniq, 
138            n_sort = mk_top_sort mod,
139            n_occ  = mkSrcVarOcc (_PK_ ((_UNPK_ fs) ++ show uniq)),
140            n_prov = LocalDef noSrcLoc NotExported }
141
142 mkIPName :: Unique -> OccName -> Name
143 mkIPName uniq occ
144   = Name { n_uniq = uniq,
145            n_sort = Local,
146            n_occ  = occ,
147            -- ZZ is this an appropriate provinence?
148            n_prov = SystemProv }
149
150 ------------------------- Wired in names -------------------------
151
152 mkWiredInIdName :: Unique -> Module -> OccName -> Id -> Name
153 mkWiredInIdName uniq mod occ id = Name { n_uniq = uniq, n_sort = WiredInId mod id,
154                                          n_occ = occ, n_prov = SystemProv }
155
156 -- mkWiredInTyConName takes a FAST_STRING instead of
157 -- an OccName, which is a bit yukky but that's what the 
158 -- clients find easiest.
159 mkWiredInTyConName :: Unique -> Module -> FAST_STRING -> TyCon -> Name
160 mkWiredInTyConName uniq mod fs tycon
161   = Name { n_uniq = uniq, n_sort = WiredInTyCon mod tycon,
162            n_occ = mkSrcOccFS tcName fs, n_prov = SystemProv }
163
164
165 ---------------------------------------------------------------------
166 mkDerivedName :: (OccName -> OccName)
167               -> Name           -- Base name
168               -> Unique         -- New unique
169               -> Name           -- Result is always a value name
170
171 mkDerivedName f name uniq = name {n_uniq = uniq, n_occ = f (n_occ name)}
172
173 -- When we renumber/rename things, we need to be
174 -- able to change a Name's Unique to match the cached
175 -- one in the thing it's the name of.  If you know what I mean.
176 setNameUnique name uniq = name {n_uniq = uniq}
177
178 setNameOcc :: Name -> OccName -> Name
179         -- Give the thing a new OccName, *and*
180         -- record that it's no longer a sys-local
181         -- This is used by the tidy-up pass
182 setNameOcc name occ = name {n_occ = occ}
183
184 setNameModule :: Name -> Module -> Name
185 setNameModule name mod = name {n_sort = set (n_sort name)}
186                        where
187                          set (Global _)             = Global mod
188                          set (WiredInId _ id)       = WiredInId mod id
189                          set (WiredInTyCon _ tycon) = WiredInTyCon mod tycon
190 \end{code}
191
192
193 %************************************************************************
194 %*                                                                      *
195 \subsection{Setting provenance and visibility
196 %*                                                                      *
197 %************************************************************************
198
199 tidyTopName is applied to top-level names in the final program
200
201 For top-level things, it globalises Local names 
202                                 (if all top-level things should be visible)
203                          and localises non-exported Global names
204                                  (if only exported things should be visible)
205
206 In all cases except an exported global, it gives it a new occurrence name.
207
208 The "visibility" here concerns whether the .o file's symbol table
209 mentions the thing; if so, it needs a module name in its symbol.
210 The Global things are "visible" and the Local ones are not
211
212 Why should things be "visible"?  Certainly they must be if they
213 are exported.  But also:
214
215 (a) In certain (prelude only) modules we split up the .hc file into
216     lots of separate little files, which are separately compiled by the C
217     compiler.  That gives lots of little .o files.  The idea is that if
218     you happen to mention one of them you don't necessarily pull them all
219     in.  (Pulling in a piece you don't need can be v bad, because it may
220     mention other pieces you don't need either, and so on.)
221     
222     Sadly, splitting up .hc files means that local names (like s234) are
223     now globally visible, which can lead to clashes between two .hc
224     files. So unlocaliseWhatnot goes through making all the local things
225     into global things, essentially by giving them full names so when they
226     are printed they'll have their module name too.  Pretty revolting
227     really.
228
229 (b) When optimisation is on we want to make all the internal
230     top-level defns externally visible
231
232 \begin{code}
233 tidyTopName :: Module -> TidyOccEnv -> Name -> (TidyOccEnv, Name)
234 tidyTopName mod env name
235   = (env', name')
236   where
237     (env', occ') = tidyOccName env (n_occ name)
238
239     name'        = Name { n_uniq = n_uniq name, n_sort = mk_top_sort mod,
240                           n_occ = occ', n_prov = LocalDef noSrcLoc NotExported }
241
242 mk_top_sort mod | all_toplev_ids_visible = Global mod
243                 | otherwise              = Local
244
245 all_toplev_ids_visible = 
246         not opt_OmitInterfacePragmas ||  -- Pragmas can make them visible
247         opt_EnsureSplittableC            -- Splitting requires visiblilty
248 \end{code}
249
250
251 \begin{code}
252 setNameProvenance :: Name -> Provenance -> Name 
253         -- setNameProvenance used to only change the provenance of 
254         -- Implicit-provenance things, but that gives bad error messages 
255         -- for names defined twice in the same module, so I changed it to 
256         -- set the provenance of *any* global (SLPJ Jun 97)
257 setNameProvenance name prov = name {n_prov = prov}
258
259 getNameProvenance :: Name -> Provenance
260 getNameProvenance name = n_prov name
261
262 setNameImportReason :: Name -> ImportReason -> Name
263 setNameImportReason name reason
264   = name { n_prov = new_prov }
265   where
266         -- It's important that we don't do the pattern matching
267         -- in the top-level clause, else we get a black hole in 
268         -- the renamer.  Rather a yukky constraint.  There's only
269         -- one call, in RnNames
270     old_prov = n_prov name
271     new_prov = case old_prov of
272                   NonLocalDef _ omit -> NonLocalDef reason omit
273                   other              -> old_prov
274 \end{code}
275
276
277 %************************************************************************
278 %*                                                                      *
279 \subsection{Provenance and export info}
280 %*                                                                      *
281 %************************************************************************
282
283 \begin{code}
284 data Provenance
285   = LocalDef                    -- Defined locally
286         SrcLoc                  -- Defn site
287         ExportFlag              -- Whether it's exported
288
289   | NonLocalDef                 -- Defined non-locally
290         ImportReason
291         PrintUnqualified
292
293   | SystemProv                  -- Either (a) a system-generated local with 
294                                 --            a v short name OccName
295                                 -- or     (b) a known-key global which should have a proper
296                                 --            provenance attached by the renamer
297 \end{code}
298
299 Sys-provs are only used internally.  When the compiler generates (say)
300 a fresh desguar variable it always calls it "ds", and of course it gets
301 a fresh unique.  But when printing -ddump-xx dumps, we must print it with
302 its unique, because there'll be a lot of "ds" variables.
303
304 Names with SystemProv differ in the following ways:
305         a) locals have unique attached when printing dumps
306         b) unifier eliminates sys tyvars in favour of user provs where possible
307         c) renamer replaces SystemProv with a better one
308
309 Before anything gets printed in interface files or output code, it's
310 fed through a 'tidy' processor, which zaps the OccNames to have
311 unique names; and converts all sys-locals to user locals
312 If any desugarer sys-locals have survived that far, they get changed to
313 "ds1", "ds2", etc.
314
315 \begin{code}
316 data ImportReason
317   = UserImport Module SrcLoc Bool       -- Imported from module M on line L
318                                         -- Note the M may well not be the defining module
319                                         -- for this thing!
320         -- The Bool is true iff the thing was named *explicitly* in the import spec,
321         -- rather than being imported as part of a group; e.g.
322         --      import B
323         --      import C( T(..) )
324         -- Here, everything imported by B, and the constructors of T
325         -- are not named explicitly; only T is named explicitly.
326         -- This info is used when warning of unused names.
327
328   | ImplicitImport                      -- Imported implicitly for some other reason
329                         
330
331 type PrintUnqualified = Bool    -- True <=> the unqualified name of this thing is
332                                 -- in scope in this module, so print it 
333                                 -- unqualified in error messages
334
335 data ExportFlag = Exported  | NotExported
336 \end{code}
337
338 Something is "Exported" if it may be mentioned by another module without
339 warning.  The crucial thing about Exported things is that they must
340 never be dropped as dead code, even if they aren't used in this module.
341 Furthermore, being Exported means that we can't see all call sites of the thing.
342
343 Exported things include:
344
345         - explicitly exported Ids, including data constructors, 
346           class method selectors
347
348         - dfuns from instance decls
349
350 Being Exported is *not* the same as finally appearing in the .o file's 
351 symbol table.  For example, a local Id may be mentioned in an Exported
352 Id's unfolding in the interface file, in which case the local Id goes
353 out too.
354
355
356 \begin{code}
357 systemProvenance :: Provenance
358 systemProvenance = SystemProv
359
360 -- pprNameProvenance is used in error messages to say where a name came from
361 pprNameProvenance :: Name -> SDoc
362 pprNameProvenance name = pprProvenance (getNameProvenance name)
363
364 pprProvenance :: Provenance -> SDoc
365 pprProvenance SystemProv             = ptext SLIT("System")
366 pprProvenance (LocalDef loc _)       = ptext SLIT("defined at")    <+> ppr loc
367 pprProvenance (NonLocalDef ImplicitImport _)
368   = ptext SLIT("implicitly imported")
369 pprProvenance (NonLocalDef (UserImport mod loc _) _) 
370   =  ptext SLIT("imported from") <+> ppr mod <+> ptext SLIT("at") <+> ppr loc
371 \end{code}
372
373
374 %************************************************************************
375 %*                                                                      *
376 \subsection{Predicates and selectors}
377 %*                                                                      *
378 %************************************************************************
379
380 \begin{code}
381 nameUnique              :: Name -> Unique
382 nameOccName             :: Name -> OccName 
383 nameModule              :: Name -> Module
384 nameSrcLoc              :: Name -> SrcLoc
385 isLocallyDefinedName    :: Name -> Bool
386 isUserExportedName      :: Name -> Bool
387 isWiredInName           :: Name -> Bool
388 isLocalName             :: Name -> Bool
389 isGlobalName            :: Name -> Bool
390 isExternallyVisibleName :: Name -> Bool
391
392
393
394 hashName :: Name -> Int
395 hashName name = IBOX( u2i (nameUnique name) )
396
397 nameUnique name = n_uniq name
398 nameOccName name = n_occ name
399
400 nameModule name =
401   case n_sort name of
402     Local -> pprPanic "nameModule" (ppr name)
403     x     -> nameSortModule x
404
405 nameSortModule (Global       mod)   = mod
406 nameSortModule (WiredInId    mod _) = mod
407 nameSortModule (WiredInTyCon mod _) = mod
408
409 nameRdrName :: Name -> RdrName
410 nameRdrName (Name { n_sort = Local, n_occ = occ }) = mkRdrUnqual occ
411 nameRdrName (Name { n_sort = sort,  n_occ = occ }) = mkRdrQual (moduleName (nameSortModule sort)) occ
412
413 isUserExportedName (Name { n_prov = LocalDef _ Exported }) = True
414 isUserExportedName other                                   = False
415
416 isUserImportedExplicitlyName (Name { n_prov = NonLocalDef (UserImport _ _ explicit) _ }) = explicit
417 isUserImportedExplicitlyName other                                                       = False
418
419 isUserImportedName (Name { n_prov = NonLocalDef (UserImport _ _ _) _ }) = True
420 isUserImportedName other                                                = False
421
422 isDynName :: Name -> Bool
423         -- Does this name come from a DLL?
424 isDynName nm = not (isLocallyDefinedName nm) && 
425                isDynamicModule (nameModule nm)
426
427 nameSrcLoc name = provSrcLoc (n_prov name)
428
429 provSrcLoc (LocalDef loc _)                     = loc        
430 provSrcLoc (NonLocalDef (UserImport _ loc _) _) = loc
431 provSrcLoc other                                = noSrcLoc   
432   
433 isLocallyDefinedName (Name {n_sort = Local})        = True      -- Local (might have SystemProv)
434 isLocallyDefinedName (Name {n_prov = LocalDef _ _}) = True      -- Global, but defined here
435 isLocallyDefinedName other                          = False     -- Other
436
437 -- Things the compiler "knows about" are in some sense
438 -- "imported".  When we are compiling the module where
439 -- the entities are defined, we need to be able to pick
440 -- them out, often in combination with isLocallyDefined.
441 isWiredInName (Name {n_sort = WiredInTyCon _ _}) = True
442 isWiredInName (Name {n_sort = WiredInId    _ _}) = True
443 isWiredInName _                                  = False
444
445 maybeWiredInIdName :: Name -> Maybe Id
446 maybeWiredInIdName (Name {n_sort = WiredInId _ id}) = Just id
447 maybeWiredInIdName other                            = Nothing
448
449 maybeWiredInTyConName :: Name -> Maybe TyCon
450 maybeWiredInTyConName (Name {n_sort = WiredInTyCon _ tc}) = Just tc
451 maybeWiredInTyConName other                               = Nothing
452
453
454 isLocalName (Name {n_sort = Local}) = True
455 isLocalName _                       = False
456
457 isGlobalName (Name {n_sort = Local}) = False
458 isGlobalName other                   = True
459
460 -- Global names are by definition those that are visible
461 -- outside the module, *as seen by the linker*.  Externally visible
462 -- does not mean visible at the source level (that's isExported).
463 isExternallyVisibleName name = isGlobalName name
464
465 hasBetterProv :: Name -> Name -> Bool
466 hasBetterProv name1 name2
467   = case n_prov name1 of
468         LocalDef _ _    -> True
469         SystemProv      -> False
470         NonLocalDef _ _ -> case n_prov name2 of
471                                 LocalDef _ _ -> False
472                                 other        -> True
473
474 isSystemName (Name {n_prov = SystemProv}) = True
475 isSystemName other                        = False
476 \end{code}
477
478
479 %************************************************************************
480 %*                                                                      *
481 \subsection[Name-instances]{Instance declarations}
482 %*                                                                      *
483 %************************************************************************
484
485 \begin{code}
486 cmpName n1 n2 = n_uniq n1 `compare` n_uniq n2
487 \end{code}
488
489 \begin{code}
490 instance Eq Name where
491     a == b = case (a `compare` b) of { EQ -> True;  _ -> False }
492     a /= b = case (a `compare` b) of { EQ -> False; _ -> True }
493
494 instance Ord Name where
495     a <= b = case (a `compare` b) of { LT -> True;  EQ -> True;  GT -> False }
496     a <  b = case (a `compare` b) of { LT -> True;  EQ -> False; GT -> False }
497     a >= b = case (a `compare` b) of { LT -> False; EQ -> True;  GT -> True  }
498     a >  b = case (a `compare` b) of { LT -> False; EQ -> False; GT -> True  }
499     compare a b = cmpName a b
500
501 instance Uniquable Name where
502     getUnique = nameUnique
503
504 instance NamedThing Name where
505     getName n = n
506 \end{code}
507
508
509 %************************************************************************
510 %*                                                                      *
511 \subsection{Pretty printing}
512 %*                                                                      *
513 %************************************************************************
514
515 \begin{code}
516 instance Outputable Name where
517         -- When printing interfaces, all Locals have been given nice print-names
518     ppr name = pprName name
519
520 pprName (Name {n_sort = Local, n_uniq = uniq, n_occ = occ, n_prov = prov})
521         -- Locals
522   = getPprStyle $ \ sty ->
523     if codeStyle sty then
524         pprUnique uniq          -- When printing in code we required all names to 
525                                 -- be globally unique; for example, we use this identifier
526                                 -- for the closure name.  So we just print the unique alone.
527     else
528         pprOccName occ <> pp_local_extra sty uniq
529   where
530     sys_local = case prov of
531                   SystemProv -> True
532                   other      -> False
533
534     pp_local_extra sty uniq
535         | sys_local      = underscore <> pprUnique uniq         -- Must print uniques for sys_locals
536         | debugStyle sty = text "{-" <> pprUnique uniq <> text "-}"
537         | otherwise      = empty
538
539
540 pprName (Name {n_sort = sort, n_uniq = uniq, n_occ = occ, n_prov = prov})
541         -- Globals, and wired in things
542   = getPprStyle $ \ sty ->
543     if codeStyle sty then
544         ppr mod <> underscore <> ppr occ
545     else
546         pp_mod_dot sty <> ppr occ <> pp_global_debug sty uniq prov
547   where
548     mod = nameSortModule sort
549
550     pp_mod_dot sty
551       = case prov of
552            SystemProv                                -> pp_qual mod user_sty
553                 -- Hack alert!  Omit the qualifier on SystemProv things in user style
554                 -- I claim such SystemProv things will also be WiredIn things.
555                 -- We can't get the omit flag right
556                 -- on wired in tycons etc (sigh) so we just leave it out in user style, 
557                 -- and hope that leaving it out isn't too consfusing.
558                 -- (e.g. if the programmer hides Bool and  redefines it.  If so, use -dppr-debug.)
559
560            LocalDef _ _                              -> pp_qual mod (user_sty || iface_sty)
561
562            NonLocalDef (UserImport imp_mod _ _) omit 
563                 | user_sty                           -> pp_qual imp_mod omit
564                 | otherwise                          -> pp_qual mod     False
565            NonLocalDef ImplicitImport           omit -> pp_qual mod     (user_sty && omit)
566       where
567         user_sty  = userStyle sty
568         iface_sty = ifaceStyle sty
569     
570     pp_qual mod omit_qual
571         | omit_qual  = empty
572         | otherwise  = pprModule mod <> dot
573     
574     pp_global_debug sty uniq prov
575       | debugStyle sty = hcat [text "{-", pprUnique uniq, prov_p prov, text "-}"]
576       | otherwise      = empty
577
578     prov_p prov | opt_PprStyle_NoPrags = empty
579                 | otherwise            = comma <> pp_prov prov
580
581 pp_prov (LocalDef _ Exported)          = char 'x'
582 pp_prov (LocalDef _ NotExported)       = char 'l'
583 pp_prov (NonLocalDef ImplicitImport _) = char 'j'
584 pp_prov (NonLocalDef (UserImport _ _ True ) _) = char 'I'       -- Imported by name
585 pp_prov (NonLocalDef (UserImport _ _ False) _) = char 'i'       -- Imported by ..
586 pp_prov SystemProv                     = char 's'
587 \end{code}
588
589
590 %************************************************************************
591 %*                                                                      *
592 \subsection{Overloaded functions related to Names}
593 %*                                                                      *
594 %************************************************************************
595
596 \begin{code}
597 class NamedThing a where
598     getOccName :: a -> OccName
599     getName    :: a -> Name
600
601     getOccName n = nameOccName (getName n)      -- Default method
602 \end{code}
603
604 \begin{code}
605 getSrcLoc           :: NamedThing a => a -> SrcLoc
606 isLocallyDefined    :: NamedThing a => a -> Bool
607 getOccString        :: NamedThing a => a -> String
608
609 getSrcLoc           = nameSrcLoc           . getName
610 isLocallyDefined    = isLocallyDefinedName . getName
611 getOccString x      = occNameString (getOccName x)
612 \end{code}
613
614 \begin{code}
615 {-# SPECIALIZE isLocallyDefined :: Name -> Bool #-}
616 \end{code}