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(..),
23 collectStmtsBinders, collectStmtBinders, collectLStmtBinders,
24 collectGroupBinders, collectHsBindLocatedBinders,
26 collectSigTysFromHsBind, collectSigTysFromHsBinds
29 #include "HsVersions.h"
39 import HscTypes ( DeprecTxt )
40 import BasicTypes ( Fixity, NewOrData )
44 import IfaceSyn ( IfaceBinding )
46 import SrcLoc ( Located(..), unLoc, noLoc )
47 import Module ( Module )
48 import Bag ( Bag, foldrBag )
51 All we actually declare here is the top-level structure for a module.
55 (Maybe (Located Module))-- Nothing => "module X where" is omitted
56 -- (in which case the next field is Nothing too)
57 (Maybe [LIE name]) -- Export list; Nothing => export list omitted, so export everything
58 -- Just [] => export *nothing*
59 -- Just [...] => as you would expect...
60 [LImportDecl name] -- We snaffle interesting stuff out of the
61 -- imported interfaces early on, adding that
62 -- info to TyDecls/etc; so this list is
63 -- often empty, downstream.
64 [LHsDecl name] -- Type, class, value, and interface signature decls
65 (Maybe DeprecTxt) -- reason/explanation for deprecation of this module
67 data HsExtCore name -- Read from Foo.hcr
70 [TyClDecl name] -- Type declarations only; just as in Haskell source,
71 -- so that we can infer kinds etc
72 [IfaceBinding] -- And the bindings
76 instance (OutputableBndr name)
77 => Outputable (HsModule name) where
79 ppr (HsModule Nothing _ imports decls _)
80 = pp_nonnull imports $$ pp_nonnull decls
82 ppr (HsModule (Just name) exports imports decls deprec)
85 Nothing -> pp_header (ptext SLIT("where"))
88 nest 8 (fsep (punctuate comma (map ppr es))),
89 nest 4 (ptext SLIT(") where"))
95 pp_header rest = case deprec of
96 Nothing -> pp_modname <+> rest
97 Just d -> vcat [ pp_modname, ppr d, rest ]
99 pp_modname = ptext SLIT("module") <+> ppr name
101 pp_nonnull [] = empty
102 pp_nonnull xs = vcat (map ppr xs)