[Restructured makeIOMatrix and its usage.
tobias@goedderz.info**20150226142003
 Ignore-this: 52968b8bc6a407c6a8cd26e088d13c88
 
 - removed the dispensable "Maybe" from makeIOMatrix's return type
 - standardized argument order regarding cll/tgt
 - clarified some comments where cll/tgt where mixed up
] hunk ./src/Igor2/RuleDevelopment/Matching.hs 83
-     if all (isVar . rhs . crul) cllrs || all (isVar . rhs . crul) tgtrs then stop
-      else do ios    <-  makeIOMatrix tgtrs o cllrs
-              maybe cancel proceed ios
+     if all (isVar . rhs . crul) cllrs || all (isVar . rhs . crul) tgtrs
+         then stop
+         else do ios <- makeIOMatrix cllrs o tgtrs
+                 if any null ios
+                     then cancel
+                     else proceed ios
+
hunk ./src/Igor2/RuleDevelopment/Matching.hs 91
-     cancel    =  logIN(--text "<Stopped by laziness!>" <$>
-                         text "Insufficient matchings!" <+>
-                         text "At least one argument had no I/Os at all!") >>
-                 return []
-     proceed m = do logDE (text "Matchings" <$> pretty (map (map pretty) m))
-                    mapM (mkIndirectCall cr n) $ sequence m
-     -- sequence computes all possibilities taking one from each list
-     stop = logIN (text "Caller or Target has variable on rhs. Would compute too many matchings") >>
-            return []
+         cancel    = do logIN (text "Insufficient matchings!" <+>
+                               text "At least one argument had no I/Os at all!")
+                        return []
+         proceed m = do logDE (text "Matchings" <$> pretty (map (map pretty) m))
+                        mapM (mkIndirectCall cr n) $ sequence m
+         -- sequence computes all possibilities taking one from each list
+         stop      = do logIN (text "Caller or Target has variable on rhs." <+>
+                               text "Would compute too many matchings.")
+                        return []
hunk ./src/Igor2/RuleDevelopment/Matching.hs 189
-{- | For n rules of the target function (t = [t1 .. tn]) and m rules of the function
-     to call (c =  [c1 .. cn]), the cross-product ( t * c) is generated as a
-     list of collumns
+{- | For n rules of the target (callee) function (t = [t1 .. tn]) and m rules of
+     the caller function (c =  [c1 .. cn]), the cross-product ( t * c) is
+     generated as a list of columns
hunk ./src/Igor2/RuleDevelopment/Matching.hs 193
-        [[t1c1  [t1c2  ... [t1cn
-         ,t2c1  ,t2c2  ... ,t2cn
+        [[c1t1  [c2t1  ... [cnt1
+         ,c1t2  ,c2t2  ... ,cnt2
hunk ./src/Igor2/RuleDevelopment/Matching.hs 196
-         ,tnc1] ,tnc2] ... ,tncn]]
+         ,c1tn] ,c2tn] ... ,cntn]]
hunk ./src/Igor2/RuleDevelopment/Matching.hs 198
-     where each 'ticj' is a list of rules resulting from @abduceIO ti o cj@.
--}
--- TODO: I thought this could wokr instead of makeIOMatrix-anyResult-oneFromEachCol,
--- but apparently it does not.
---makeIOMatrix :: [CovrRule] -> Ordering -> [CovrRule] -> IM (Maybe [[(Ordering, [Rule])]])
---makeIOMatrix tgtrs o cllrs = nothingIfAnyEmpty
---    [ nothingIfAnyEmpty [abduceIO t o c | t <- tgtrs ] | c <- cllrs]
---    where
---    nothingIfAnyEmpty = (liftM sequence) . sequence
-    
-makeIOMatrix :: [CovrRule] -> Ordering -> [CovrRule] -> IM (Maybe [[(Ordering, [Rule])]])
-makeIOMatrix tgtrs o cllrs =
-    liftM sequence $ sequence [ anyResult [abduceIO t o c | t <- tgtrs ] | c <- cllrs]
+     where each 'citj' is a list of rules resulting from @abduceIO ti o cj@.
hunk ./src/Igor2/RuleDevelopment/Matching.hs 200
-anyResult :: [IM (Maybe a)] -> IM (Maybe [a])
-anyResult = liftM (nullToNothing . catMaybes) . sequence
-    where nullToNothing [] = Nothing
-          nullToNothing xs = Just xs
+     The where clause is for documentation purposes only (obviously).
+-}
+makeIOMatrix :: [CovrRule] -> Ordering -> [CovrRule] -> IM [[(Ordering, [Rule])]]
+makeIOMatrix cllrs o tgtrs =
+    sequence [ liftM catMaybes $ sequence [abduceIO c o t | t <- tgtrs ] | c <- cllrs]
+        where sequence :: [IM a] -> IM [a]
+              sequence = Control.Monad.sequence
hunk ./src/Igor2/RuleDevelopment/Matching.hs 208
-oneFromEachCol []    = [[]]
-oneFromEachCol (x:xs)= [e:es | e <- x, es <- (oneFromEachCol xs)]
--- | @abduceIO tgt o cll@ abduces one IO pair for each argument of 'tgt' if
---   admissible. It is not admissible to call 'cll' from 'tgt' if the difference
+-- | @abduceIO cll o tgt@ abduces one IO pair for each argument of 'tgt' if
+--   admissible. It is not admissible to call 'tgt' from 'cll' if the difference
hunk ./src/Igor2/RuleDevelopment/Matching.hs 213
-abduceIO tgt maxcallrel cll = do
+abduceIO cll maxcallrel tgt = do
hunk ./src/Igor2/RuleDevelopment/Matching.hs 246
-                               return.Just $ (callrel, map (rule lhss') rhss')
+                               return $ Just (callrel, map (rule lhss') rhss')