[project @ 1997-07-05 03:02:04 by sof]
[ghc-hetmet.git] / ghc / compiler / basicTypes / FieldLabel.lhs
index 53a1b57..ccaf094 100644 (file)
@@ -10,15 +10,25 @@ module FieldLabel where
 
 IMP_Ubiq(){-uitous-}
 
-import Name            ( Name{-instance Eq/Outputable-} )
-import Type            ( Type(..) )
+import Name            ( Name{-instance Eq/Outputable-}, NamedThing(..), nameUnique )
+import Type            ( SYN_IE(Type) )
+
+import Outputable
+import Unique           ( Uniquable(..) )
 \end{code}
 
 \begin{code}
 data FieldLabel
-  = FieldLabel Name
-               Type
-               FieldLabelTag
+  = FieldLabel Name            -- Also used as the Name of the field selector Id
+               Type            -- Type of the field; may have free type variables that
+                               -- are the tyvar of the constructor
+                               -- e.g.  data T a = MkT { op1 :: a -> a, op2 :: a -> Int }
+                               -- The type in the FieldLabel for op1 will be simply (a->a).
+
+               FieldLabelTag   -- Indicates position within constructor
+                               -- If the same field occurs in more than one constructor
+                               -- then it'll have a separate FieldLabel on each occasion,
+                               -- but with a single name (and presumably the same type!)
 
 type FieldLabelTag = Int
 
@@ -42,4 +52,7 @@ instance Outputable FieldLabel where
 
 instance NamedThing FieldLabel where
     getName (FieldLabel n _ _) = n
+
+instance Uniquable FieldLabel where
+    uniqueOf (FieldLabel n _ _) = nameUnique n
 \end{code}