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(..), defaultFixity,
21 RecFlag(..), isRec, isNonRec,
22 TopLevelFlag(..), isTopLevel, isNotTopLevel
25 #include "HsVersions.h"
30 %************************************************************************
32 \subsection[Unused]{Unused}
34 %************************************************************************
36 Used as a placeholder in types.
42 unused = error "Unused is used!"
46 %************************************************************************
48 \subsection[Arity]{Arity}
50 %************************************************************************
57 %************************************************************************
59 \subsection[Version]{Module and identifier version numbers}
61 %************************************************************************
68 %************************************************************************
70 \subsection[Fixity]{Fixity info}
72 %************************************************************************
75 data Fixity = Fixity Int FixityDirection
76 data FixityDirection = InfixL | InfixR | InfixN
79 instance Outputable Fixity where
80 ppr (Fixity prec dir) = hcat [ppr dir, space, int prec]
82 instance Outputable FixityDirection where
83 ppr InfixL = ptext SLIT("infixl")
84 ppr InfixR = ptext SLIT("infixr")
85 ppr InfixN = ptext SLIT("infix")
87 instance Eq Fixity where -- Used to determine if two fixities conflict
88 (Fixity p1 dir1) == (Fixity p2 dir2) = p1==p2 && dir1 == dir2
91 defaultFixity = Fixity 9 InfixL
95 %************************************************************************
97 \subsection[NewType/DataType]{NewType/DataType flag}
99 %************************************************************************
103 = NewType -- "newtype Blah ..."
104 | DataType -- "data Blah ..."
105 | EnumType -- Enumeration; all constructors are nullary
106 deriving( Eq ) -- Needed because Demand derives Eq
109 %************************************************************************
111 \subsection[Top-level/local]{Top-level/not-top level flag}
113 %************************************************************************
120 isTopLevel, isNotTopLevel :: TopLevelFlag -> Bool
122 isNotTopLevel NotTopLevel = True
123 isNotTopLevel TopLevel = False
125 isTopLevel TopLevel = True
126 isTopLevel NotTopLevel = False
129 %************************************************************************
131 \subsection[Recursive/Non-Recursive]{Recursive/Non-Recursive flag}
133 %************************************************************************
136 data RecFlag = Recursive
139 isRec :: RecFlag -> Bool
140 isRec Recursive = True
141 isRec NonRecursive = False
143 isNonRec :: RecFlag -> Bool
144 isNonRec Recursive = False
145 isNonRec NonRecursive = True