On Sat, 14 Nov 2009, Jason Dagit wrote:

Sat Nov 14 14:31:05 PST 2009  Jason Dagit <[email protected]>
 * clean up elegant_merge

-elegant_merge (p1 :\/: p2) =
-  case commutex (p1 :< invert p2) of
-  Just (ip2':<p1') -> case commutex (p1' :< p2) of
-                      Nothing -> Nothing -- should be a redundant check
-                      Just (_:<p1o) -> if unsafeCompare p1o p1
-                                       then Just (invert ip2' :/\: p1')
-                                       else Nothing
-  Nothing -> Nothing
+elegant_merge (p1 :\/: p2) = do
+  ip2' :< p1' <- commutex (p1 :< invert p2)
+  _ :< p1o <- commutex (p1' :< p2)
+  if unsafeCompare p1o p1 -- should be a redundant check
+    then return $ invert ip2' :/\: p1'
+    else Nothing

You've moved the "should be a redundant check" comment from the second commutex call to the unsafeCompare. I guess that the comment really should cover both of these things, do you agree?

BTW the code could be further elegantised by using "guard".

If you agree about the comment, I suggest I accept this patch as it stands, particularly since other stuff depends on it, and one of us sends a follow-on to clarify the comment.

Sat Nov 14 14:42:43 PST 2009  Jason Dagit <[email protected]>
 * replace commutex with commute in elegant_merge

Looks fine.

Ganesh
_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to