[turn the Pred type alias into a data type
Helmut Grohne <grohne@cs.uni-bonn.de>**20150311113953
 Ignore-this: eedf2f9f8422b250c9d4cd21fb918a4f
 
 Previously Pred was a Type with a value "AppT (ConT n) t". By turning it into a
 data type. This assumption can be enforced by the compiler.
] hunk ./src/Igor2/RuleDevelopment/Cata.hs 217
-                 [ AppT (conT ''Mu) (varT "a")
-                 , AppT fctr (AppT pctr (varT "a"))]
+                 [ mkPred ''Mu "a"
+                 , Pred fctrname (AppT pctr (varT "a"))]
hunk ./src/Igor2/RuleDevelopment/Cata.hs 223
-                 [ AppT (conT ''Mu) (varT "a")
-                 , AppT fctr (AppT pctr (varT "a"))]
+                 [ mkPred ''Mu "a"
+                 , Pred fctrname (AppT pctr (varT "a"))]
hunk ./src/Igor2/RuleDevelopment/Cata.hs 227
-fctr = conT (mkName "Generics.Pointless.Functors.Functor")
+fctrname = mkName "Generics.Pointless.Functors.Functor"
+fctr = conT fctrname
hunk ./src/Syntax/Builder.hs 123
-        pClssSupr   = [(toName cn, concatMap getVarNames (getPreds assts))]
+        pClssSupr   = [(toName cn, concatMap (getVarNames . predMember) (getPreds assts))]
hunk ./src/Syntax/Builder.hs 411
-    getPred (Hs.ClassA n ts) = map ((appT (conT (toName n))) . toType) ts
-    getPred p             = error $ errorMsg "toType" p 
+    getPred (Hs.ClassA n ts) = map (Pred (toName n) . toType) ts
+    getPred p             = error $ errorMsg "toType" p
hunk ./src/Syntax/Ppr.hs 16
-import Syntax.Type (typeOf, Type(..), TyCxt)
+import Syntax.Type (typeOf, Type(..), TyCxt, Pred, predClass, predMember)
hunk ./src/Syntax/Ppr.hs 95
-          
+
+pprPred :: Pred -> Doc
+pprPred p = pretty (predClass p) <+> parens (pretty (predMember p))
+
hunk ./src/Syntax/Ppr.hs 101
-pprCxt [t] = pretty t <+> text "=>"
-pprCxt ts  = parens (hsep $ punctuate comma $ map pretty ts) <+> text "=>"
+pprCxt [t] = pprPred t <+> text "=>"
+pprCxt ts  = parens (hsep $ punctuate comma $ map pprPred ts) <+> text "=>"
hunk ./src/Syntax/Type.hs 21
+    -- ** Predicates
+    Pred(Pred), predClass, predMember,
hunk ./src/Syntax/Type.hs 24
-    Pred, TyCxt, QualTy,
+    TyCxt, QualTy,
hunk ./src/Syntax/Type.hs 70
-type Pred   = Type -- assumes Type to be 'AppT (ConT n) t', where 'n' is a class name
-type TyCxt = [Pred] 
+data Pred = Pred {predClass :: Name, predMember :: Type} deriving (Show, Ord, Eq)
+type TyCxt = [Pred]
hunk ./src/Syntax/Type.hs 73
-mkPred :: Name -> String -> Type
-mkPred n v = AppT (ConT n) (varT v)
+mkPred :: Name -> String -> Pred
+mkPred n v = Pred n (varT v)
hunk ./src/Syntax/Type.hs 241
-    -- occur in both, the type and the context 
-    quantifiedVars :: Type -> TyCxt -> [Name]   
-    quantifiedVars t = (intersect (getVarNames t)) . (concatMap getVarNames)
-quantify t@(AppT _ _) qtys = quantify (ForallT [] [] t) qtys   
+    -- occur in both, the type and the context
+    quantifiedVars :: Type -> TyCxt -> [Name]
+    quantifiedVars t = intersect (getVarNames t) . concatMap (getVarNames . predMember)
+quantify t@(AppT _ _) qtys = quantify (ForallT [] [] t) qtys
hunk ./src/Syntax/Type.hs 266
--- | True if the type (used as a type repdicate) qualifies any of the given 
---   variable names 
-isIn :: [Name] -> Pred -> Bool     
-isIn ns p = any (\n -> n `elem` ns) (getVarNames p)        
+-- | True if the type (used as a type repdicate) qualifies any of the given
+--   variable names
+isIn :: [Name] -> Pred -> Bool
+isIn ns p = any (`elem` ns) (getVarNames (predMember p))
hunk ./src/Syntax/UnifyTy.hs 71
-
+matchesPred :: Monad m => Pred -> Pred -> C m Bool
+matchesPred (Pred n1 t1) (Pred n2 t2) = if n1 == n2 then matches t1 t2 else return False
hunk ./src/Syntax/UnifyTy.hs 100
-satisfies t p@(AppT (ConT n) _) = getInstances n >>= anyM (flip matches t)
+satisfies t p = getInstances (predClass p) >>= anyM (flip matches t)
hunk ./src/Syntax/UnifyTy.hs 127
-inHnf (AppT (ConT n) t) = hnf t
+inHnf = hnf . predMember
hunk ./src/Syntax/UnifyTy.hs 139
-     b1 <- mapM bySuper ctx >>= (anyM (`matches` p)) . concat
-     b2 <- byInst p >>= maybe (return False) (allM (entails ctx)) 
+     b1 <- mapM bySuper ctx >>= anyM (`matchesPred` p) . concat
+     b2 <- byInst p >>= maybe (return False) (allM (entails ctx))
hunk ./src/Syntax/UnifyTy.hs 146
-bySuper p@(AppT (ConT n) t) =  
-    getSuperClasses n >>= mapM (\n' -> bySuper (AppT (ConT n') t)) >>= 
+bySuper p@(Pred n t) =
+    getSuperClasses n >>= mapM (\n' -> bySuper (Pred n' t)) >>=
hunk ./src/Syntax/UnifyTy.hs 152
-byInst p@(AppT (ConT n) t) = do
+byInst p@(Pred n t) = do
hunk ./src/Syntax/UnifyTy.hs 155
-    return $ msum is    
-    
-tryInst :: Monad m => Pred -> Type -> C m (Maybe [Pred])
-tryInst t (ForallT _ c t') = liftM (\u -> Just (map (apply u) c)) (match t t')
-                             `safeCatchErrorC` (const (return Nothing))
+    return $ msum is
+
+tryInst :: Monad m => Type -> Type -> C m (Maybe [Pred])
+tryInst t (ForallT _ c t') = liftM (\u -> Just (map (\(Pred n t'') -> Pred n (apply u t'')) c)) (match t t')
+                             `safeCatchErrorC` const (return Nothing)
hunk ./src/Syntax/UnifyTy.hs 194
-collectPreds vnm is (ForallT _ c (VarT _)) = liftM concat $ mapM (\(AppT (ConT n) _) -> bySuper $ mkPred n vnm) c
+collectPreds vnm is (ForallT _ c (VarT _)) = liftM concat $ mapM (\p -> bySuper $ mkPred (predClass p) vnm) c
