Haskell: Show de derivação para tipo personalizado
Tenho esta definição de tipo:
data Operace = Op (Int->Int->Int) String (Int->Int->Int) deriving Show
Quero imprimir esse tipo no shell interativo (GHCi). Tudo o que deve ser impresso é oString
campo.
Tentei o seguinte:
instance Show Operace where
show (Op op str inv) = show str
Mas eu continuo recebendo
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)
Eu não quero adicionarShow
para(Int->Int->Int)
, tudo o que quero imprimir é a sequênci
Obrigado pela ajuda!
EDITAR
Para referência futura, a versão fixa é:
data Operace = Op (Int->Int->Int) String (Int->Int->Int)
instance Show Operace where
show (Op op str inv) = str