12/04/08 22:19:51.16
>>82
一応さ、型クラス使った方が良いと思うので貼っとくね
Animalに動物足すたびに代数データ型を変更するのはアレなんで
class Animal a where
voice :: a -> String
data Dog = Dog deriving (Eq, Show)
instance Animal Dog where
voice _ = "wan wan!"
data Cat = Cat deriving (Eq, Show)
instance Animal Cat where
voice _ = "nya- nya-!"
taro = (Dog, "taro", 7)
mii = (Cat, "mii", 3)