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,
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
96 %************************************************************************
98 \subsection[NewType/DataType]{NewType/DataType flag}
100 %************************************************************************
104 = NewType -- "newtype Blah ..."
105 | DataType -- "data Blah ..."
106 | EnumType -- Enumeration; all constructors are nullary
107 deriving( Eq ) -- Needed because Demand derives Eq
110 %************************************************************************
112 \subsection[Top-level/local]{Top-level/not-top level flag}
114 %************************************************************************
121 isTopLevel, isNotTopLevel :: TopLevelFlag -> Bool
123 isNotTopLevel NotTopLevel = True
124 isNotTopLevel TopLevel = False
126 isTopLevel TopLevel = True
127 isTopLevel NotTopLevel = False
130 %************************************************************************
132 \subsection[Recursive/Non-Recursive]{Recursive/Non-Recursive flag}
134 %************************************************************************
137 data RecFlag = Recursive
140 isRec :: RecFlag -> Bool
141 isRec Recursive = True
142 isRec NonRecursive = False
144 isNonRec :: RecFlag -> Bool
145 isNonRec Recursive = False
146 isNonRec NonRecursive = True