[project @ 1997-05-26 04:57:23 by sof]
[ghc-hetmet.git] / ghc / compiler / basicTypes / BasicTypes.lhs
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1997
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 #include "HsVersions.h"
17
18 module BasicTypes(
19         SYN_IE(Version), SYN_IE(Arity),
20         SYN_IE(Module), moduleString, pprModule,
21         Fixity(..), FixityDirection(..),
22         NewOrData(..)
23    ) where
24
25 IMP_Ubiq()
26
27 import Pretty
28 import Outputable
29
30 \end{code}
31
32 %************************************************************************
33 %*                                                                      *
34 \subsection[Arity]{Arity}
35 %*                                                                      *
36 %************************************************************************
37
38 \begin{code}
39 type Arity = Int
40 \end{code}
41
42
43 %************************************************************************
44 %*                                                                      *
45 \subsection[Version]{Module and identifier version numbers}
46 %*                                                                      *
47 %************************************************************************
48
49 \begin{code}
50 type Version = Int
51 \end{code}
52
53
54 %************************************************************************
55 %*                                                                      *
56 \subsection[Module]{The name of a module}
57 %*                                                                      *
58 %************************************************************************
59
60 \begin{code}
61 type Module   = FAST_STRING
62
63 moduleString :: Module -> String
64 moduleString mod = _UNPK_ mod
65
66 pprModule :: PprStyle -> Module -> Doc
67 pprModule sty m = ptext m
68 \end{code}
69
70
71 %************************************************************************
72 %*                                                                      *
73 \subsection[Fixity]{Fixity info}
74 %*                                                                      *
75 %************************************************************************
76
77 \begin{code}
78 data Fixity = Fixity Int FixityDirection
79 data FixityDirection = InfixL | InfixR | InfixN 
80                      deriving(Eq)
81
82 instance Outputable Fixity where
83     ppr sty (Fixity prec dir) = hcat [ppr sty dir, space, int prec]
84
85 instance Outputable FixityDirection where
86     ppr sty InfixL = ptext SLIT("infixl")
87     ppr sty InfixR = ptext SLIT("infixr")
88     ppr sty InfixN = ptext SLIT("infix")
89
90 instance Eq Fixity where                -- Used to determine if two fixities conflict
91   (Fixity p1 dir1) == (Fixity p2 dir2) = p1==p2 && dir1 == dir2
92 \end{code}
93
94
95 %************************************************************************
96 %*                                                                      *
97 \subsection[NewType/DataType]{NewType/DataType flag}
98 %*                                                                      *
99 %************************************************************************
100
101 \begin{code}
102 data NewOrData
103   = NewType         -- "newtype Blah ..."
104   | DataType        -- "data Blah ..."
105   deriving( Eq )
106 \end{code}