I want to have this nice, clean way to describe an object's properties with functions and pattern matching:
data Animal = Cat | Dog | Cow
isBig :: Animal -> Bool
isLoyal :: Animal -> Bool
-- many more possible properties, including complicated non-bools, methods, and whatnot
--- Describing Cat
isBig Cat = False
isLoyal Cat = False
--- more properties
--- Describing Dog
isBig Dog = False
isLoyal Dog = True
--- more properties
--- Describing Cow
isBig Cow = True
isLoyal Cow = False
--- more properties
However, this gives an error about multiple declarations. Because, apparently, function definition via pattern-matching must be done in consecutive lines.
Is it indicative that my approach is wrong, un-Haskell-like? Or is it just a flaw in the language? Or do I misunderstand something?
isBig,isLoyal, and so on, and making typesDog,Cat, andCowwhich implement this class. This is pretty different, though: classes are open, unlike types.