15 Nov 13:05
Re: Could someone teach me why we use Data.Monoid?
Nicolas Pouillard <nicolas.pouillard <at> gmail.com>
2009-11-15 12:05:08 GMT
2009-11-15 12:05:08 GMT
Excerpts from Daniel Schüssler's message of Sun Nov 15 07:51:35 +0100 2009: > Hi, Hi, > -- Invariant 1: There are never two adjacent Lefts or two adjacent Rights [...] > normalize (Left a0 : Left a1 : as) = Left (mappend a0 a1) : normalize as > normalize (Right a0 : Right a1 : as) = Right (mappend a0 a1) : normalize as If you want to preserve your invariant, I think you should do : normalize (Left a0 : Left a1 : as) = normalize (Left (mappend a0 a1) : as) normalize (Right a0 : Right a1 : as) = normalize (Right (mappend a0 a1) : as) However, maybe it is correct if you only call normalize on (xs ++ ys) where xs and ys are already normalized so that you have only one point where you can break this invariant. Regards, -- -- Nicolas Pouillard http://nicolaspouillard.fr
RSS Feed