2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section{Haskell abstract syntax definition}
6 This module glues together the pieces of the Haskell abstract syntax,
7 which is declared in the various \tr{Hs*} modules. This module,
8 therefore, is almost nothing but re-exporting.
22 HsModule(..), HsExtCore(..)
25 #include "HsVersions.h"
35 import HscTypes ( DeprecTxt )
36 import BasicTypes ( Fixity )
40 import IfaceSyn ( IfaceBinding )
42 import SrcLoc ( Located(..) )
43 import Module ( Module )
46 All we actually declare here is the top-level structure for a module.
50 (Maybe (Located Module))-- Nothing => "module X where" is omitted
51 -- (in which case the next field is Nothing too)
52 (Maybe [LIE name]) -- Export list; Nothing => export list omitted, so export everything
53 -- Just [] => export *nothing*
54 -- Just [...] => as you would expect...
55 [LImportDecl name] -- We snaffle interesting stuff out of the
56 -- imported interfaces early on, adding that
57 -- info to TyDecls/etc; so this list is
58 -- often empty, downstream.
59 [LHsDecl name] -- Type, class, value, and interface signature decls
60 (Maybe DeprecTxt) -- reason/explanation for deprecation of this module
62 data HsExtCore name -- Read from Foo.hcr
65 [TyClDecl name] -- Type declarations only; just as in Haskell source,
66 -- so that we can infer kinds etc
67 [IfaceBinding] -- And the bindings
71 instance (OutputableBndr name)
72 => Outputable (HsModule name) where
74 ppr (HsModule Nothing _ imports decls _)
75 = pp_nonnull imports $$ pp_nonnull decls
77 ppr (HsModule (Just name) exports imports decls deprec)
80 Nothing -> pp_header (ptext SLIT("where"))
83 nest 8 (fsep (punctuate comma (map ppr es))),
84 nest 4 (ptext SLIT(") where"))
90 pp_header rest = case deprec of
91 Nothing -> pp_modname <+> rest
92 Just d -> vcat [ pp_modname, ppr d, rest ]
94 pp_modname = ptext SLIT("module") <+> ppr name
97 pp_nonnull xs = vcat (map ppr xs)