[BUGFIX in match and unify, applyL and matechesWithSubsLs added
martin.hofmann@uni-bamberg.de**20090610075302
 BUGFIX in match and unify: swapped arguments and special Case for TListE and TInfixE for cons lists
] hunk ./src/Syntax/Expressions.hs 108
-        braces $ pretty e1 <+> pretty e2  <+> colon <> colon <+> pretty t
+        braces $ pretty e1 <+> pretty e2 <+> colon <> colon <+> pretty t
hunk ./src/Syntax/Expressions.hs 197
-    root (TListE (l:ls) t)                  = \[l, TListE ls t] -> TListE (l:ls) t 
+    root (TListE (l:ls) lt)                  = 
+        \[l,ls] -> case ls of 
+                    (TListE ls' t) -> TListE (l:ls') t
+                    expr             -> TInfixE l (TConE '(:) $ mkArrowT [typeOf l, lt, lt]) expr lt
hunk ./src/Syntax/Expressions.hs 246
-        matchVar s t
-    match s@(TVarE _ _) t                   = checkMatch s t >> matchVar s t
-    match s          t@(TVarE _ _)          = flush "No Match!"
+        matchVar t s
+    match s@(TVarE _ _) t                   = nomatch "match"
+    match s          t@(TVarE _ _)          = checkMatch s t >> matchVar t s
hunk ./src/Syntax/Expressions.hs 252
-        if (ns == nt) then return () else flush "No Match!"  
+        if (ns == nt) then return () else nomatch "match" 
hunk ./src/Syntax/Expressions.hs 256
-        if (l1 == l2) then return () else flush "No Match!" 
+        if (l1 == l2) then return () else nomatch "match"
hunk ./src/Syntax/Expressions.hs 265
-            _owise               -> flush "No Match!" 
+            _owise               -> nomatch "match"
hunk ./src/Syntax/Expressions.hs 270
-            _owise             -> flush "No Match!" 
+            _owise             -> nomatch "match"
hunk ./src/Syntax/Expressions.hs 278
-        checkMatch s t >> if isNil n then return () else flush "No Match!"  
+        checkMatch s t >> if isNil n then return () else nomatch "match"
hunk ./src/Syntax/Expressions.hs 280
-        checkMatch s t >> if isNil n then return () else flush "No Match!" 
+        checkMatch s t >> if isNil n then return () else nomatch "match"
hunk ./src/Syntax/Expressions.hs 292
-            _owise       -> flush "No Match!"  
+            _owise       -> nomatch "match"
+    match s@(TListE (se:sl) st) t@(TInfixE te (TConE n _) tl _)  = do
+        checkMatch s t
+        if isCons n 
+           then match se te >> match (TListE sl st) tl
+           else nomatch ("match1" ++ (show.pretty $  n))
+    match t@(TInfixE te (TConE n _) tl _) s@(TListE (se:sl) st)  = do
+        checkMatch t s
+        if isCons n 
+           then match te se >> match tl (TListE sl st)
+           else nomatch "match2"
hunk ./src/Syntax/Expressions.hs 310
-          else flush "No Match!"        
+          else nomatch "match"
hunk ./src/Syntax/Expressions.hs 313
-    match s t                               = flush "No Match!"
+    match s t = nomatch $ "match\n" ++ (show s) ++ "\n" ++ (show t)
hunk ./src/Syntax/Expressions.hs 371
-            _owise       -> flush "No Match!"  
+            _owise       -> flush "No unifiable!"  
+    unify s@(TListE (se:sl) st) t@(TInfixE te (TConE n _) tl _)  = do
+        checkUnify s t
+        if isCons n 
+           then unify se te >> unify (TListE sl st) tl
+           else flush "Not unifiable"
+    unify t@(TInfixE te (TConE n _) tl _) s@(TListE (se:sl) st)  = do
+        checkUnify s t
+        if isCons n 
+           then unify se te >> unify tl (TListE sl st)
+           else flush "Not unifiable"
hunk ./src/Syntax/Expressions.hs 453
-                            let tcone = TConE (mkName ":") (mkArrowT [ety, lty, lty]) 
+                            let tcone = TConE '(:) (mkArrowT [ety, lty, lty]) 
hunk ./src/Syntax/Expressions.hs 639
-toPat (TLitE n _)         = LitP n
+toPat (TLitE l _)         = LitP l
hunk ./src/Syntax/Expressions.hs 1066
+nomatch s = flush $ "Expressions." ++ s ++ ": No Match!"
hunk ./src/Syntax/Expressions.hs 1222
+rhs0 = TListE [TVarE (mkName "b") (VarT (mkName "a"))] (AppT ListT (VarT (mkName "a")))
hunk ./src/Syntax/Expressions.hs 1225
-
+rhs3 = TInfixE (TVarE (mkName "x0") (VarT (mkName "a"))) 
+               (TConE '(:)
+                      (AppT (AppT ArrowT (VarT (mkName "a"))) 
+                            (AppT (AppT ArrowT 
+                                       (AppT ListT (VarT (mkName "a")))) 
+                                  (AppT ListT (VarT (mkName "a")))))) 
+               (TVarE (mkName "x1") (AppT ListT (VarT (mkName "a")))) 
+               (AppT ListT (VarT (mkName "a")))
+               
+               
hunk ./src/Syntax/Unifier.hs 9
+    matchesWithSubsLs,
hunk ./src/Syntax/Unifier.hs 56
---s1 @@ s2 = return $ [(u, apply s1 t) | (u,t) <- s2] ++ s1
- 
+--s1 @@ s2 = liftM (++s1) $ sequence [liftM  (\v -> (u, v)) (apply s1 t) | (u,t) <- s2]
+--
hunk ./src/Syntax/Unifier.hs 62
+    
+    applyL :: (Substitutable a) => (Substitution a) -> [a] -> LM [a]
+    applyL s = mapM (apply s)
hunk ./src/Syntax/Unifier.hs 115
-            if (val == t) then return () else flush "No Match!"
+            if (val == t) then return () else flush "matchVar: No Match!"
hunk ./src/Syntax/Unifier.hs 182
-        Nothing   -> flush "No Match!"
+        Nothing   -> flush "matchLs: No Match!"
hunk ./src/Syntax/Unifier.hs 188
-        Nothing -> flush "Not unifiable" 
+        Nothing -> flush "unifyLs: Not unifiable" 
hunk ./src/Syntax/Unifier.hs 190
-
+matchesWithSubsLs :: (Unifiable t ) => [t] -> [t]  -> LM (Substitution t)
+matchesWithSubsLs l1 l2 = mws l1 l2 nullSubst
+    where
+    mws [] [] s = return s
+    mws [] _ s  = fail "matchesWithSubsLs: No Match!"
+    mws _ [] s  = fail "matchesWithSubsLs: No Match!"
+    mws (x:xs) (y:ys) s = 
+        do s' <- execStateT (match x y) s
+           mws xs ys s'