module FieldLabel where
-import Ubiq{-uitous-}
+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
instance NamedThing FieldLabel where
getName (FieldLabel n _ _) = n
+
+instance Uniquable FieldLabel where
+ uniqueOf (FieldLabel n _ _) = nameUnique n
\end{code}