2 % (c) The GRASP/AQUA Project, Glasgow University, 1997-1998
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 Fixity(..), FixityDirection(..), StrictnessMark(..),
20 NewOrData(..), IfaceFlavour(..), TopLevelFlag(..), RecFlag(..)
23 #include "HsVersions.h"
28 %************************************************************************
30 \subsection[Unused]{Unused}
32 %************************************************************************
34 Used as a placeholder in types.
40 unused = error "Unused is used!"
44 %************************************************************************
46 \subsection[Arity]{Arity}
48 %************************************************************************
55 %************************************************************************
57 \subsection[Version]{Module and identifier version numbers}
59 %************************************************************************
66 %************************************************************************
68 \subsection[IfaceFlavour]{IfaceFlavour}
70 %************************************************************************
72 The IfaceFlavour type is used mainly in an imported Name's Provenance
73 to say whether the name comes from a regular .hi file, or whether it comes
74 from a hand-written .hi-boot file. This is important, because it has to be
79 A.hs imports C {-# SOURCE -#} ( f )
81 Then in A.hi we may mention C.f, in an inlining. When compiling B we *must not*
82 read C.f's details from C.hi, even if the latter happens to exist from an earlier
83 compilation run. So we use the name "C!f" in A.hi, and when looking for an interface
84 file with details of C!f we look in C.hi-boot. The "!" stuff is recorded in the
85 IfaceFlavour in the Name of C.f in A.
87 Not particularly beautiful, but it works.
90 data IfaceFlavour = HiFile -- The interface was read from a standard interface file
91 | HiBootFile -- ... or from a handwritten "hi-boot" interface file
93 instance Text IfaceFlavour where -- Just used in debug prints of lex tokens
94 showsPrec n HiFile s = s
95 showsPrec n HiBootFile s = "!" ++ s
99 %************************************************************************
101 \subsection[Fixity]{Fixity info}
103 %************************************************************************
106 data Fixity = Fixity Int FixityDirection
107 data FixityDirection = InfixL | InfixR | InfixN
110 instance Outputable Fixity where
111 ppr (Fixity prec dir) = hcat [ppr dir, space, int prec]
113 instance Outputable FixityDirection where
114 ppr InfixL = ptext SLIT("infixl")
115 ppr InfixR = ptext SLIT("infixr")
116 ppr InfixN = ptext SLIT("infix")
118 instance Eq Fixity where -- Used to determine if two fixities conflict
119 (Fixity p1 dir1) == (Fixity p2 dir2) = p1==p2 && dir1 == dir2
123 %************************************************************************
125 \subsection[NewType/DataType]{NewType/DataType flag}
127 %************************************************************************
131 = NewType -- "newtype Blah ..."
132 | DataType -- "data Blah ..."
133 | EnumType -- Enumeration; all constructors are nullary
134 deriving( Eq ) -- Needed because Demand derives Eq
137 The @RecFlag@ tells whether the thing is part of a recursive group or not.
140 %************************************************************************
142 \subsection[Top-level/local]{Top-level/not-top level flag}
144 %************************************************************************
153 %************************************************************************
155 \subsection[Top-level/local]{Top-level/not-top level flag}
157 %************************************************************************
160 data RecFlag = Recursive
164 %************************************************************************
166 \subsection{Strictness indication}
168 %************************************************************************
171 data StrictnessMark = MarkedStrict