Parse and desugar equational constraints
[ghc-hetmet.git] / compiler / hsSyn / HsTypes.lhs
index ad7facb..a4ac865 100644 (file)
@@ -1,7 +1,9 @@
 %
+% (c) The University of Glasgow 2006
 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
 %
-\section[HsTypes]{Abstract syntax: user-defined types}
+
+HsTypes: Abstract syntax: user-defined types
 
 \begin{code}
 module HsTypes (
@@ -30,14 +32,11 @@ module HsTypes (
 
 import {-# SOURCE #-} HsExpr ( HsSplice, pprSplice )
 
-import Type            ( Type )
-import {- Kind parts of -} 
-       Type            ( {- instance Outputable Kind -} Kind,
-                         pprParendKind, pprKind, isLiftedTypeKind )
-import HsDoc            ( LHsDoc, HsDoc )
-import BasicTypes      ( IPName, Boxity, tupleParens )
-import SrcLoc          ( Located(..), unLoc, noSrcSpan )
-import StaticFlags     ( opt_PprStyle_Debug )
+import Type
+import HsDoc
+import BasicTypes
+import SrcLoc
+import StaticFlags
 import Outputable
 \end{code}
 
@@ -103,7 +102,8 @@ type HsContext name = [LHsPred name]
 
 type LHsPred name = Located (HsPred name)
 
-data HsPred name = HsClassP name [LHsType name]
+data HsPred name = HsClassP name [LHsType name]                 -- class constraint
+                | HsEqualP (LHsType name) (LHsType name)-- equality constraint
                 | HsIParam (IPName name) (LHsType name)
 
 type LHsType name = Located (HsType name)
@@ -269,9 +269,6 @@ splitHsFunType other                   = ([], other)
 %*                                                                     *
 %************************************************************************
 
-NB: these types get printed into interface files, so 
-    don't change the printing format lightly
-
 \begin{code}
 instance (OutputableBndr name) => Outputable (HsType name) where
     ppr ty = pprHsType ty
@@ -281,8 +278,13 @@ instance (Outputable name) => Outputable (HsTyVarBndr name) where
     ppr (KindedTyVar name kind) = pprHsTyVarBndr name kind
 
 instance OutputableBndr name => Outputable (HsPred name) where
-    ppr (HsClassP clas tys) = ppr clas <+> hsep (map (pprParendHsType.unLoc) tys)
-    ppr (HsIParam n ty)    = hsep [ppr n, dcolon, ppr ty]
+    ppr (HsClassP clas tys) = ppr clas <+> hsep (map pprLHsType tys)
+    ppr (HsEqualP t1 t2)    = hsep [pprLHsType t1, ptext SLIT("~"), 
+                                   pprLHsType t2]
+    ppr (HsIParam n ty)     = hsep [ppr n, dcolon, ppr ty]
+
+pprLHsType :: OutputableBndr name => LHsType name -> SDoc
+pprLHsType = pprParendHsType . unLoc
 
 pprHsTyVarBndr :: Outputable name => name -> Kind -> SDoc
 pprHsTyVarBndr name kind | isLiftedTypeKind kind = ppr name