Reputation: 3573
I made these data types to represent guitar tabs and I'm trying to write the show
function to print them as real guitar tabs. data
s are not my specialty and I'm having trouble matching up the types.
The error is
Equations for `show' have different numbers of arguments In the instance declaration for GHC.Show.Show Tabs.Chord'
The code:
type Strings = Int
data Fret = None | Note Int
instance Show Fret where
show None = "-"
show (Note a) = show a
data Chord = EmptyChord Strings | Chord [Fret]
instance Show Chord where
show EmptyChord a = init $ take (a * 2) ['-', '\n' ..]
show Chord (x : xs) = x : '\n' : show xs
Upvotes: 2
Views: 4563
Reputation: 1766
The second instance needs more parentheses:
instance Show Chord where
show (EmptyChord a) = init $ take (a * 2) ['-', '\n' ..]
show (Chord (x : xs)) = x : '\n' : show xs
Upvotes: 7