Brady Dean
Brady Dean

Reputation: 3573

Equation has different number of arguments

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. datas 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

Answers (1)

Jeremy List
Jeremy List

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

Related Questions