私はこの型定義を持っています:
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
forを追加したくありません(Int->Int->Int)
。印刷したいのは文字列だけです。
手伝ってくれてありがとう!
編集:
今後の参考のために、修正されたバージョンは次のとおりです。
data Operace = Op (Int->Int->Int) String (Int->Int->Int)
instance Show Operace where
show (Op _ str _) = str