2 % (c) The University of Glasgow 2006
3 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
5 \section{Haskell abstract syntax definition}
7 This module glues together the pieces of the Haskell abstract syntax,
8 which is declared in the various \tr{Hs*} modules. This module,
9 therefore, is almost nothing but re-exporting.
13 -- The above warning supression flag is a temporary kludge.
14 -- While working on this module you are encouraged to remove it and fix
15 -- any warnings in the module. See
16 -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
31 HsModule(..), HsExtCore(..),
37 #include "HsVersions.h"
47 import BasicTypes ( Fixity, DeprecTxt )
52 import IfaceSyn ( IfaceBinding )
54 import SrcLoc ( Located(..) )
55 import Module ( Module, ModuleName )
58 All we actually declare here is the top-level structure for a module.
62 (Maybe (Located ModuleName))-- Nothing => "module X where" is omitted
63 -- (in which case the next field is Nothing too)
64 (Maybe [LIE name]) -- Export list; Nothing => export list omitted, so export everything
65 -- Just [] => export *nothing*
66 -- Just [...] => as you would expect...
67 [LImportDecl name] -- We snaffle interesting stuff out of the
68 -- imported interfaces early on, adding that
69 -- info to TyDecls/etc; so this list is
70 -- often empty, downstream.
71 [LHsDecl name] -- Type, class, value, and interface signature decls
72 (Maybe DeprecTxt) -- reason/explanation for deprecation of this module
73 (Maybe String) -- Haddock options, declared with the {-# DOCOPTIONS ... #-} pragma
74 (HaddockModInfo name) -- Haddock module info
75 (Maybe (HsDoc name)) -- Haddock module description
77 data HaddockModInfo name = HaddockModInfo {
78 hmi_description :: Maybe (HsDoc name),
79 hmi_portability :: Maybe String,
80 hmi_stability :: Maybe String,
81 hmi_maintainer :: Maybe String
84 emptyHaddockModInfo :: HaddockModInfo a
85 emptyHaddockModInfo = HaddockModInfo {
86 hmi_description = Nothing,
87 hmi_portability = Nothing,
88 hmi_stability = Nothing,
89 hmi_maintainer = Nothing
92 data HsExtCore name -- Read from Foo.hcr
95 [TyClDecl name] -- Type declarations only; just as in Haskell source,
96 -- so that we can infer kinds etc
97 [IfaceBinding] -- And the bindings
102 instance Outputable Char where
105 instance (OutputableBndr name)
106 => Outputable (HsModule name) where
108 ppr (HsModule Nothing _ imports decls _ _ _ mbDoc)
109 = pp_mb mbDoc $$ pp_nonnull imports $$ pp_nonnull decls
111 ppr (HsModule (Just name) exports imports decls deprec opts _ mbDoc)
115 Nothing -> pp_header (ptext SLIT("where"))
118 nest 8 (fsep (punctuate comma (map ppr es))),
119 nest 4 (ptext SLIT(") where"))
125 pp_header rest = case deprec of
126 Nothing -> pp_modname <+> rest
127 Just d -> vcat [ pp_modname, ppr d, rest ]
129 pp_modname = ptext SLIT("module") <+> ppr name
131 pp_mb (Just x) = ppr x
132 pp_mb Nothing = empty
134 pp_nonnull [] = empty
135 pp_nonnull xs = vcat (map ppr xs)