Remove bogus assertion
[ghc.git] / compiler / backpack / BkpSyn.hs
1 -- | This is the syntax for bkp files which are parsed in 'ghc --backpack'
2 -- mode. This syntax is used purely for testing purposes.
3
4 module BkpSyn (
5 -- * Backpack abstract syntax
6 HsUnitId(..),
7 LHsUnitId,
8 HsModuleSubst,
9 LHsModuleSubst,
10 HsModuleId(..),
11 LHsModuleId,
12 HsComponentId(..),
13 LHsUnit, HsUnit(..),
14 LHsUnitDecl, HsUnitDecl(..),
15 HsDeclType(..),
16 IncludeDecl(..),
17 LRenaming, Renaming(..),
18 ) where
19
20 import GhcPrelude
21
22 import HsSyn
23 import SrcLoc
24 import Outputable
25 import Module
26 import PackageConfig
27
28 {-
29 ************************************************************************
30 * *
31 User syntax
32 * *
33 ************************************************************************
34 -}
35
36 data HsComponentId = HsComponentId {
37 hsPackageName :: PackageName,
38 hsComponentId :: ComponentId
39 }
40
41 instance Outputable HsComponentId where
42 ppr (HsComponentId _pn cid) = ppr cid -- todo debug with pn
43
44 data HsUnitId n = HsUnitId (Located n) [LHsModuleSubst n]
45 type LHsUnitId n = Located (HsUnitId n)
46
47 type HsModuleSubst n = (Located ModuleName, LHsModuleId n)
48 type LHsModuleSubst n = Located (HsModuleSubst n)
49
50 data HsModuleId n = HsModuleVar (Located ModuleName)
51 | HsModuleId (LHsUnitId n) (Located ModuleName)
52 type LHsModuleId n = Located (HsModuleId n)
53
54 -- | Top level @unit@ declaration in a Backpack file.
55 data HsUnit n = HsUnit {
56 hsunitName :: Located n,
57 hsunitBody :: [LHsUnitDecl n]
58 }
59 type LHsUnit n = Located (HsUnit n)
60
61 -- | A declaration in a package, e.g. a module or signature definition,
62 -- or an include.
63 data HsDeclType = ModuleD | SignatureD
64 data HsUnitDecl n
65 = DeclD HsDeclType (Located ModuleName) (Maybe (Located (HsModule GhcPs)))
66 | IncludeD (IncludeDecl n)
67 type LHsUnitDecl n = Located (HsUnitDecl n)
68
69 -- | An include of another unit
70 data IncludeDecl n = IncludeDecl {
71 idUnitId :: LHsUnitId n,
72 idModRenaming :: Maybe [ LRenaming ],
73 -- | Is this a @dependency signature@ include? If so,
74 -- we don't compile this include when we instantiate this
75 -- unit (as there should not be any modules brought into
76 -- scope.)
77 idSignatureInclude :: Bool
78 }
79
80 -- | Rename a module from one name to another. The identity renaming
81 -- means that the module should be brought into scope.
82 data Renaming = Renaming { renameFrom :: Located ModuleName
83 , renameTo :: Maybe (Located ModuleName) }
84 type LRenaming = Located Renaming