2 % (c) The GRASP/AQUA Project, Glasgow University, 1997
4 \section[BasicTypes]{Miscellanous types}
6 This module defines a miscellaneously collection of very simple
10 \item have no other obvious home
11 \item don't depend on any other complicated types
12 \item are used in more than one "part" of the compiler
16 #include "HsVersions.h"
19 SYN_IE(Version), SYN_IE(Arity),
20 SYN_IE(Module), moduleString, pprModule,
21 Fixity(..), FixityDirection(..),
22 NewOrData(..), IfaceFlavour(..)
32 %************************************************************************
34 \subsection[Arity]{Arity}
36 %************************************************************************
43 %************************************************************************
45 \subsection[Version]{Module and identifier version numbers}
47 %************************************************************************
54 %************************************************************************
56 \subsection[Module]{The name of a module}
58 %************************************************************************
61 type Module = FAST_STRING
63 moduleString :: Module -> String
64 moduleString mod = _UNPK_ mod
66 pprModule :: PprStyle -> Module -> Doc
67 pprModule sty m = ptext m
70 %************************************************************************
72 \subsection[IfaceFlavour]{IfaceFlavour}
74 %************************************************************************
76 The IfaceFlavour type is used mainly in an imported Name's Provenance
77 to say whether the name comes from a regular .hi file, or whether it comes
78 from a hand-written .hi-boot file. This is important, because it has to be
83 A.hs imports C {-# SOURCE -#} ( f )
85 Then in A.hi we may mention C.f, in an inlining. When compiling B we *must not*
86 read C.f's details from C.hi, even if the latter happens to exist from an earlier
87 compilation run. So we use the name "C!f" in A.hi, and when looking for an interface
88 file with details of C!f we look in C.hi-boot. The "!" stuff is recorded in the
89 IfaceFlavour in the Name of C.f in A.
91 Not particularly beautiful, but it works.
94 data IfaceFlavour = HiFile -- The interface was read from a standard interface file
95 | HiBootFile -- ... or from a handwritten "hi-boot" interface file
97 instance Text IfaceFlavour where -- Just used in debug prints of lex tokens
98 showsPrec n HiFile s = s
99 showsPrec n HiBootFile s = "!" ++ s
103 %************************************************************************
105 \subsection[Fixity]{Fixity info}
107 %************************************************************************
110 data Fixity = Fixity Int FixityDirection
111 data FixityDirection = InfixL | InfixR | InfixN
114 instance Outputable Fixity where
115 ppr sty (Fixity prec dir) = hcat [ppr sty dir, space, int prec]
117 instance Outputable FixityDirection where
118 ppr sty InfixL = ptext SLIT("infixl")
119 ppr sty InfixR = ptext SLIT("infixr")
120 ppr sty InfixN = ptext SLIT("infix")
122 instance Eq Fixity where -- Used to determine if two fixities conflict
123 (Fixity p1 dir1) == (Fixity p2 dir2) = p1==p2 && dir1 == dir2
127 %************************************************************************
129 \subsection[NewType/DataType]{NewType/DataType flag}
131 %************************************************************************
135 = NewType -- "newtype Blah ..."
136 | DataType -- "data Blah ..."