方程具有不同数量的参数 [英] Equation has different number of arguments

查看:59
本文介绍了方程具有不同数量的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了这些数据类型来表示吉他谱,而我试图编写show函数以将它们打印为真实的吉他谱. data不是我的专长,我在匹配类型方面遇到困难.

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.

错误是

'show'的方程具有不同数量的参数 在GHC.Show.Show Tabs.Chord的实例声明中

Equations for `show' have different numbers of arguments In the instance declaration for 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

推荐答案

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

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

这篇关于方程具有不同数量的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆