在 ghci 中:
λ> :t (pure 1)
(pure 1) :: (Applicative f, Num a) => f a
λ> show (pure 1)
<interactive>:1:1:
No instance for (Show (f0 a0))
arising from a use of `show'
Possible fix: add an instance declaration for (Show (f0 a0))
In the expression: show (pure 1)
In an equation for `it': it = show (pure 1)
λ> pure 1
1
这是否意味着 ghci 执行 Applicative 并显示结果,就像IO
?
请注意,pure ()
不要pure (+1)
打印任何内容。