[project @ 1999-01-27 14:51:14 by simonpj]
[ghc-hetmet.git] / ghc / compiler / basicTypes / BasicTypes.lhs
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1997-1998
3 %
4 \section[BasicTypes]{Miscellanous types}
5
6 This module defines a miscellaneously collection of very simple
7 types that
8
9 \begin{itemize}
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
13 \end{itemize}
14
15 \begin{code}
16 module BasicTypes(
17         Version, Arity, 
18         Unused, unused,
19         Fixity(..), FixityDirection(..), StrictnessMark(..),
20         NewOrData(..), TopLevelFlag(..), RecFlag(..)
21    ) where
22
23 #include "HsVersions.h"
24
25 import Outputable
26 \end{code}
27
28 %************************************************************************
29 %*                                                                      *
30 \subsection[Unused]{Unused}
31 %*                                                                      *
32 %************************************************************************
33
34 Used as a placeholder in types.
35
36 \begin{code}
37 type Unused = ()
38
39 unused :: Unused
40 unused = error "Unused is used!"
41 \end{code}
42
43
44 %************************************************************************
45 %*                                                                      *
46 \subsection[Arity]{Arity}
47 %*                                                                      *
48 %************************************************************************
49
50 \begin{code}
51 type Arity = Int
52 \end{code}
53
54
55 %************************************************************************
56 %*                                                                      *
57 \subsection[Version]{Module and identifier version numbers}
58 %*                                                                      *
59 %************************************************************************
60
61 \begin{code}
62 type Version = Int
63 \end{code}
64
65
66 %************************************************************************
67 %*                                                                      *
68 \subsection[Fixity]{Fixity info}
69 %*                                                                      *
70 %************************************************************************
71
72 \begin{code}
73 data Fixity = Fixity Int FixityDirection
74 data FixityDirection = InfixL | InfixR | InfixN 
75                      deriving(Eq)
76
77 instance Outputable Fixity where
78     ppr (Fixity prec dir) = hcat [ppr dir, space, int prec]
79
80 instance Outputable FixityDirection where
81     ppr InfixL = ptext SLIT("infixl")
82     ppr InfixR = ptext SLIT("infixr")
83     ppr InfixN = ptext SLIT("infix")
84
85 instance Eq Fixity where                -- Used to determine if two fixities conflict
86   (Fixity p1 dir1) == (Fixity p2 dir2) = p1==p2 && dir1 == dir2
87 \end{code}
88
89
90 %************************************************************************
91 %*                                                                      *
92 \subsection[NewType/DataType]{NewType/DataType flag}
93 %*                                                                      *
94 %************************************************************************
95
96 \begin{code}
97 data NewOrData
98   = NewType     -- "newtype Blah ..."
99   | DataType    -- "data Blah ..."
100   | EnumType    -- Enumeration; all constructors are nullary
101   deriving( Eq )        -- Needed because Demand derives Eq
102 \end{code}
103
104 The @RecFlag@ tells whether the thing is part of a recursive group or not.
105
106
107 %************************************************************************
108 %*                                                                      *
109 \subsection[Top-level/local]{Top-level/not-top level flag}
110 %*                                                                      *
111 %************************************************************************
112
113 \begin{code}
114 data TopLevelFlag
115   = TopLevel
116   | NotTopLevel
117 \end{code}
118
119
120 %************************************************************************
121 %*                                                                      *
122 \subsection[Top-level/local]{Top-level/not-top level flag}
123 %*                                                                      *
124 %************************************************************************
125
126 \begin{code} 
127 data RecFlag = Recursive 
128              | NonRecursive
129 \end{code}
130
131 %************************************************************************
132 %*                                                                      *
133 \subsection{Strictness indication}
134 %*                                                                      *
135 %************************************************************************
136
137 \begin{code}
138 data StrictnessMark = MarkedStrict
139                     | NotMarkedStrict
140 \end{code}