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
19 Module, moduleString, pprModule,
20 Fixity(..), FixityDirection(..),
21 NewOrData(..), IfaceFlavour(..), TopLevelFlag(..), RecFlag(..)
24 #include "HsVersions.h"
29 %************************************************************************
31 \subsection[Unused]{Unused}
33 %************************************************************************
35 Used as a placeholder in types.
41 unused = error "Unused is used!"
45 %************************************************************************
47 \subsection[Arity]{Arity}
49 %************************************************************************
56 %************************************************************************
58 \subsection[Version]{Module and identifier version numbers}
60 %************************************************************************
67 %************************************************************************
69 \subsection[Module]{The name of a module}
71 %************************************************************************
74 type Module = FAST_STRING
76 moduleString :: Module -> String
77 moduleString mod = _UNPK_ mod
79 pprModule :: Module -> SDoc
83 %************************************************************************
85 \subsection[IfaceFlavour]{IfaceFlavour}
87 %************************************************************************
89 The IfaceFlavour type is used mainly in an imported Name's Provenance
90 to say whether the name comes from a regular .hi file, or whether it comes
91 from a hand-written .hi-boot file. This is important, because it has to be
96 A.hs imports C {-# SOURCE -#} ( f )
98 Then in A.hi we may mention C.f, in an inlining. When compiling B we *must not*
99 read C.f's details from C.hi, even if the latter happens to exist from an earlier
100 compilation run. So we use the name "C!f" in A.hi, and when looking for an interface
101 file with details of C!f we look in C.hi-boot. The "!" stuff is recorded in the
102 IfaceFlavour in the Name of C.f in A.
104 Not particularly beautiful, but it works.
107 data IfaceFlavour = HiFile -- The interface was read from a standard interface file
108 | HiBootFile -- ... or from a handwritten "hi-boot" interface file
110 instance Text IfaceFlavour where -- Just used in debug prints of lex tokens
111 showsPrec n HiFile s = s
112 showsPrec n HiBootFile s = "!" ++ s
116 %************************************************************************
118 \subsection[Fixity]{Fixity info}
120 %************************************************************************
123 data Fixity = Fixity Int FixityDirection
124 data FixityDirection = InfixL | InfixR | InfixN
127 instance Outputable Fixity where
128 ppr (Fixity prec dir) = hcat [ppr dir, space, int prec]
130 instance Outputable FixityDirection where
131 ppr InfixL = ptext SLIT("infixl")
132 ppr InfixR = ptext SLIT("infixr")
133 ppr InfixN = ptext SLIT("infix")
135 instance Eq Fixity where -- Used to determine if two fixities conflict
136 (Fixity p1 dir1) == (Fixity p2 dir2) = p1==p2 && dir1 == dir2
140 %************************************************************************
142 \subsection[NewType/DataType]{NewType/DataType flag}
144 %************************************************************************
148 = NewType -- "newtype Blah ..."
149 | DataType -- "data Blah ..."
150 deriving( Eq ) -- Needed because Demand derives Eq
153 The @RecFlag@ tells whether the thing is part of a recursive group or not.
156 %************************************************************************
158 \subsection[Top-level/local]{Top-level/not-top level flag}
160 %************************************************************************
169 %************************************************************************
171 \subsection[Top-level/local]{Top-level/not-top level flag}
173 %************************************************************************
176 data RecFlag = Recursive
180 %************************************************************************
182 \subsection{Strictness indication}
184 %************************************************************************
187 data StrictnessMark = MarkedStrict