我有这种类型的定义:
data Operace = Op (Int->Int->Int) String (Int->Int->Int) deriving Show
Run Code Online (Sandbox Code Playgroud)
我想将此类型打印到交互式shell(GHCi)中.所有应该打印的是该String领域.
我试过这个:
instance Show Operace where
show (Op op str inv) = show str
Run Code Online (Sandbox Code Playgroud)
但我仍然坚持下去
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 …Run Code Online (Sandbox Code Playgroud)