data BTree a = Empty | Node a (BTree a) (BTree a) deriving Show
type Aluno = (Numero,Nome,Regime,Classificacao)
type Numero = Int
type Nome = String
data Regime = ORD | TE | MEL deriving Show
data Classificacao = Aprov Int| Rep| Faltou deriving Show
type Turma = BTree Aluno
我有这个功能,计算有多少“Alunos”有Regime TE。我怎样才能比较变量与Haskell中的数据类型?
我的代码:
numeroT :: Eq => Turma -> Int
numeroT Empty = 0
numeroT (Node (x,_,r,_) e d) = if (r==TE) then 1+((numeroT e)+(numeroT d))
else (numeroT e)+(numeroT d)
我不能用TE比较r
?获取Eq
错误。
在未来,请当你遇到这样的问题,增加了整个错误消息。 “'Eq'错误”可能是很多完全不同的东西。 – leftaroundabout 2015-02-08 17:08:52
感谢您的提示。我的第一个问题。抱歉。 – 2015-02-08 17:52:56