口粮:
class Foo s where
myCons :: Char -> s -> s
myCons c xs = <my definition of however I wish to interpret this>
instance (Eq, Show) Foo where
(:) x y = x `myCons` y
错误:
Pattern bindings (except simple variables) not allowed in instance declaration:
(:) x y = x `myCons` y
我做错什么了?
我想要做的事情:
fooFromList :: [Int] -> Foo
fooFromList [] = Foo []
fooFromList (x:xs) = let x' = (convertDigitToChar x) in x':(fooFromList xs)