[project @ 1999-04-06 09:44:27 by simonm]
[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 {-# SOURCE #-} DataCon ( DataCon )
26 import {-# SOURCE #-} Type    ( Type )
27 import Outputable
28 \end{code}
29
30 %************************************************************************
31 %*                                                                      *
32 \subsection[Unused]{Unused}
33 %*                                                                      *
34 %************************************************************************
35
36 Used as a placeholder in types.
37
38 \begin{code}
39 type Unused = ()
40
41 unused :: Unused
42 unused = error "Unused is used!"
43 \end{code}
44
45
46 %************************************************************************
47 %*                                                                      *
48 \subsection[Arity]{Arity}
49 %*                                                                      *
50 %************************************************************************
51
52 \begin{code}
53 type Arity = Int
54 \end{code}
55
56
57 %************************************************************************
58 %*                                                                      *
59 \subsection[Version]{Module and identifier version numbers}
60 %*                                                                      *
61 %************************************************************************
62
63 \begin{code}
64 type Version = Int
65 \end{code}
66
67
68 %************************************************************************
69 %*                                                                      *
70 \subsection[Fixity]{Fixity info}
71 %*                                                                      *
72 %************************************************************************
73
74 \begin{code}
75 data Fixity = Fixity Int FixityDirection
76 data FixityDirection = InfixL | InfixR | InfixN 
77                      deriving(Eq)
78
79 instance Outputable Fixity where
80     ppr (Fixity prec dir) = hcat [ppr dir, space, int prec]
81
82 instance Outputable FixityDirection where
83     ppr InfixL = ptext SLIT("infixl")
84     ppr InfixR = ptext SLIT("infixr")
85     ppr InfixN = ptext SLIT("infix")
86
87 instance Eq Fixity where                -- Used to determine if two fixities conflict
88   (Fixity p1 dir1) == (Fixity p2 dir2) = p1==p2 && dir1 == dir2
89 \end{code}
90
91
92 %************************************************************************
93 %*                                                                      *
94 \subsection[NewType/DataType]{NewType/DataType flag}
95 %*                                                                      *
96 %************************************************************************
97
98 \begin{code}
99 data NewOrData
100   = NewType     -- "newtype Blah ..."
101   | DataType    -- "data Blah ..."
102   | EnumType    -- Enumeration; all constructors are nullary
103   deriving( Eq )        -- Needed because Demand derives Eq
104 \end{code}
105
106 %************************************************************************
107 %*                                                                      *
108 \subsection[Top-level/local]{Top-level/not-top level flag}
109 %*                                                                      *
110 %************************************************************************
111
112 \begin{code}
113 data TopLevelFlag
114   = TopLevel
115   | NotTopLevel
116 \end{code}
117
118 %************************************************************************
119 %*                                                                      *
120 \subsection[Recursive/Non-Recursive]{Recursive/Non-Recursive flag}
121 %*                                                                      *
122 %************************************************************************
123
124 \begin{code} 
125 data RecFlag = Recursive 
126              | NonRecursive
127 \end{code}
128
129 %************************************************************************
130 %*                                                                      *
131 \subsection{Strictness indication}
132 %*                                                                      *
133 %************************************************************************
134
135 \begin{code}
136 data StrictnessMark = MarkedStrict
137                     | MarkedUnboxed DataCon [Type]
138                     | NotMarkedStrict
139 \end{code}