1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
%
\section[HsImpExp]{Abstract syntax: imports, exports, interfaces}
\begin{code}
#include "HsVersions.h"
module HsImpExp where
IMP_Ubiq()
import Name ( pprNonSym )
import Outputable
import PprStyle ( PprStyle(..) )
import Pretty
import SrcLoc ( SrcLoc )
\end{code}
%************************************************************************
%* *
\subsection{Import and export declaration lists}
%* *
%************************************************************************
One per \tr{import} declaration in a module.
\begin{code}
data ImportDecl name
= ImportDecl Module -- module name
Bool -- True => qualified
(Maybe Module) -- as Module
(Maybe (Bool, [IE name])) -- (True => hiding, names)
SrcLoc
\end{code}
\begin{code}
instance (NamedThing name, Outputable name) => Outputable (ImportDecl name) where
ppr sty (ImportDecl mod qual as spec _)
= ppHang (ppCat [ppPStr SLIT("import"), pp_qual qual, ppPStr mod, pp_as as])
4 (pp_spec spec)
where
pp_qual False = ppNil
pp_qual True = ppPStr SLIT("qualified")
pp_as Nothing = ppNil
pp_as (Just a) = ppBeside (ppPStr SLIT("as ")) (ppPStr a)
pp_spec Nothing = ppNil
pp_spec (Just (False, spec))
= ppParens (interpp'SP sty spec)
pp_spec (Just (True, spec))
= ppBeside (ppPStr SLIT("hiding ")) (ppParens (interpp'SP sty spec))
\end{code}
%************************************************************************
%* *
\subsection{Imported and exported entities}
%* *
%************************************************************************
\begin{code}
data IE name
= IEVar name
| IEThingAbs name -- Class/Type (can't tell)
| IEThingAll name -- Class/Type plus all methods/constructors
| IEThingWith name [name] -- Class/Type plus some methods/constructors
| IEModuleContents Module -- (Export Only)
\end{code}
\begin{code}
instance (NamedThing name, Outputable name) => Outputable (IE name) where
ppr sty (IEVar var) = pprNonSym sty var
ppr sty (IEThingAbs thing) = ppr sty thing
ppr sty (IEThingAll thing)
= ppBesides [ppr sty thing, ppStr "(..)"]
ppr sty (IEThingWith thing withs)
= ppBeside (ppr sty thing)
(ppParens (ppInterleave ppComma (map (pprNonSym sty) withs)))
ppr sty (IEModuleContents mod)
= ppBeside (ppPStr SLIT("module ")) (ppPStr mod)
\end{code}
|