在 GHCi 中运行以下命令会在 上抛出错误,stuff' 4
但在 上不会抛出错误stuff 4
。为什么?
有办法修复吗?我想使用MkStuff'
而不是MkStuff
。
ghci>
:{
class MkStuff s m | m -> s where
stuff:: s -> m ()
instance MkStuff Int IO where
stuff = print
class MkStuff' s m | m -> s where
stuff' :: s -> m
instance MkStuff' Int (IO ()) where
stuff' = print
:}
ghci> stuff 4
4
ghci> stuff' 4
<interactive>:16:1: error: [GHC-39999]
• No instance for ‘MkStuff' Integer ()’ arising from a use of ‘it’
• In the first argument of ‘print’, namely ‘it’
In a stmt of an interactive GHCi command: print it