On 8/10/07, Andrew Coppin <[EMAIL PROTECTED]> wrote: > > My program needs to make decisions based on a pair of boolean values. > Encoding both values as a single algebraic data type means I have to > keep "taking it apart" so I can work with it. I'm not sure how much time > this wastes...
Incidentally, there is an argument that many (perhaps most) use of Bool should instead be custom datatypes. That is, instead of: type FooBar = (Bool, Bool) one should instead do something like data Foo = Foo | AntiFoo data Bar = Baz | Bo type FooBar = (Foo, Bar) which makes it clearer what's going on and harder to confuse the two booleans. Of course, now you have to replace \(foo, bar) -> if foo then ... else ... with \(foo, bar) -> if foo == Foo then ... else ... or \(foo, bar) -> case foo of { Foo -> ...; Bar -> ... } ---- Actually, that raises an interesting question. Is there a performance difference between "if foo == Foo ..." and "case Foo of ..."? I think JHC's case-hoisting should be able to transform the former into the latter, but does it? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe