方程有不同数量的参数

Bra*_*ean 2 haskell types

我制作了这些数据类型来表示吉他标签,我正在尝试编写show功能,将它们打印为真正的吉他标签.datas不是我的专长,我在匹配类型时遇到了麻烦.

错误是

"show"的等式在GHC.Show.Show Tabs.Chord'的实例声明中有不同数量的参数

代码:

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
Run Code Online (Sandbox Code Playgroud)

Jer*_*ist 6

第二个实例需要更多括号:

instance Show Chord where
  show (EmptyChord a) = init $ take (a * 2) ['-', '\n' ..]
  show (Chord (x : xs)) = x : '\n' : show xs
Run Code Online (Sandbox Code Playgroud)