
Bulat Ziganshin wrote:
type classes is universal answer to almost any question ;)
Argh! Every complex problem has a simple and wrong answer, huh? At some point you should stop generalizing, because doing everything equally bad is the same as doing nothing right (but requires more work).
data B = F | T deriving Boolean
Now is toBool :: Silliness -> Bool equivalent to isSilly or to isSensible? See, the gain in readability is... uhm... questionable.
btw,
class Enum a => Boolean a where fromBool :: Bool -> a toBool :: a -> Bool fromBool = fromEnum.toEnum toBool = fromEnum.toEnum
btw, fromBool :: Enum b => Bool -> b fromBool = fromEnum.toEnum toBool :: Enum b => b -> Bool toBool = fromEnum.toEnum is a lot simpler and exactly as useful (read: not at all). Udo. PS: No, I don't think 'perhaps' is all that useful. It lacks obvious semantics and is easily defined should you need it, in which case you also know how it should behave. -- I loathe people who keep dogs. They are cowards who haven't got the guts to bite people themselves. -- August Strindberg