017383303ac7798fca903f2d06bc69b311e3d6c8
[ghc-hetmet.git] / ghc / compiler / basicTypes / FieldLabel.lhs
1 %
2 % (c) The AQUA Project, Glasgow University, 1996
3 %
4 \section[FieldLabel]{The @FieldLabel@ type}
5
6 \begin{code}
7 #include "HsVersions.h"
8
9 module FieldLabel where
10
11 IMP_Ubiq(){-uitous-}
12
13 import Name             --( Name{-instance Eq/Outputable-}, nameUnique )
14 import Type             ( SYN_IE(Type) )
15
16 import Outputable
17 import UniqFM           ( SYN_IE(Uniquable) )
18 \end{code}
19
20 \begin{code}
21 data FieldLabel
22   = FieldLabel  Name            -- Also used as the Name of the field selector Id
23                 Type
24                 FieldLabelTag
25
26 type FieldLabelTag = Int
27
28 mkFieldLabel = FieldLabel
29
30 firstFieldLabelTag :: FieldLabelTag
31 firstFieldLabelTag = 1
32
33 allFieldLabelTags :: [FieldLabelTag]
34 allFieldLabelTags = [1..]
35
36 fieldLabelName (FieldLabel n _  _)   = n
37 fieldLabelType (FieldLabel _ ty _)   = ty
38 fieldLabelTag  (FieldLabel _ _  tag) = tag
39
40 instance Eq FieldLabel where
41     (FieldLabel n1 _ _) == (FieldLabel n2 _ _) = n1 == n2
42
43 instance Outputable FieldLabel where
44     ppr sty (FieldLabel n _ _) = ppr sty n
45
46 instance NamedThing FieldLabel where
47     getName (FieldLabel n _ _) = n
48
49 instance Uniquable FieldLabel where
50     uniqueOf (FieldLabel n _ _) = nameUnique n
51 \end{code}