У меня есть такое определение типа:
data Operace = Op (Int->Int->Int) String (Int->Int->Int) deriving Show
Я хочу напечатать этот тип в интерактивной оболочке (GHCi). Все, что нужно напечатать, - это поле String
.
Я пробовал это:
instance Show Operace where
show (Op op str inv) = show str
Но я все еще получаю
No instance for (Show (Int -> Int -> Int))
arising from the 'deriving' clause of a data type declaration
Possible fix:
add an instance declaration for (Show (Int -> Int -> Int))
or use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
When deriving the instance for (Show Operace)
Я не хочу добавлять Show
для (Int-> Int-> Int)
, все, что я хочу напечатать, - это строка.
Спасибо за помощь!
РЕДАКТИРОВАТЬ:
Для справки в будущем фиксированная версия:
data Operace = Op (Int->Int->Int) String (Int->Int->Int)
instance Show Operace where
show (Op _ str _) = str