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(..),
20 defaultFixity, maxPrecedence, negateFixity, negatePrecedence,
22 RecFlag(..), isRec, isNonRec,
23 TopLevelFlag(..), isTopLevel, isNotTopLevel
26 #include "HsVersions.h"
31 %************************************************************************
33 \subsection[Unused]{Unused}
35 %************************************************************************
37 Used as a placeholder in types.
43 unused = error "Unused is used!"
47 %************************************************************************
49 \subsection[Arity]{Arity}
51 %************************************************************************
58 %************************************************************************
60 \subsection[Version]{Module and identifier version numbers}
62 %************************************************************************
69 %************************************************************************
71 \subsection[Fixity]{Fixity info}
73 %************************************************************************
76 data Fixity = Fixity Int FixityDirection
77 data FixityDirection = InfixL | InfixR | InfixN
80 instance Outputable Fixity where
81 ppr (Fixity prec dir) = hcat [ppr dir, space, int prec]
83 instance Outputable FixityDirection where
84 ppr InfixL = ptext SLIT("infixl")
85 ppr InfixR = ptext SLIT("infixr")
86 ppr InfixN = ptext SLIT("infix")
88 instance Eq Fixity where -- Used to determine if two fixities conflict
89 (Fixity p1 dir1) == (Fixity p2 dir2) = p1==p2 && dir1 == dir2
91 maxPrecedence = (9::Int)
92 defaultFixity = Fixity maxPrecedence InfixL
94 negateFixity :: Fixity
95 negateFixity = Fixity negatePrecedence InfixL -- Precedence of unary negate is wired in as infixl 6!
97 negatePrecedence :: Int
102 %************************************************************************
104 \subsection[NewType/DataType]{NewType/DataType flag}
106 %************************************************************************
110 = NewType -- "newtype Blah ..."
111 | DataType -- "data Blah ..."
112 | EnumType -- Enumeration; all constructors are nullary
113 deriving( Eq ) -- Needed because Demand derives Eq
116 %************************************************************************
118 \subsection[Top-level/local]{Top-level/not-top level flag}
120 %************************************************************************
127 isTopLevel, isNotTopLevel :: TopLevelFlag -> Bool
129 isNotTopLevel NotTopLevel = True
130 isNotTopLevel TopLevel = False
132 isTopLevel TopLevel = True
133 isTopLevel NotTopLevel = False
136 %************************************************************************
138 \subsection[Recursive/Non-Recursive]{Recursive/Non-Recursive flag}
140 %************************************************************************
143 data RecFlag = Recursive
146 isRec :: RecFlag -> Bool
147 isRec Recursive = True
148 isRec NonRecursive = False
150 isNonRec :: RecFlag -> Bool
151 isNonRec Recursive = False
152 isNonRec NonRecursive = True