In the code below, I define an algebraic data type and I (attempt to) make it an instance of Show. However, I'm getting a compile-time error (included below). What am I doing wrong?
I believe I'm using the correct syntax (atleast as per this post). For context, I'm working Problem #13 in '99 Haskell Problems'
data RepeatType a = Multiple (Int, a) | Single a
instance Show RepeatType where
show (Multiple (n,x)) = "(" ++ n ++ " " ++ show x ++ ")"
show (Single x) = show x
I'm getting the following compile-time error:
test.hs:3:15:
Expecting one more argument to `RepeatType'
In the instance declaration for `Show RepeatType'
Failed, modules loaded: none.
For example, the goal is for it to work as follows in GHCi:
ghci> Multiple (5,'C')
(5 C)
ghci> Single 'D'
D
EDIT: Sorry for the totally irrelevant post title - changed now.