λ> :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
いApplicativeの実行GHCiのとちょうど同じようIO
、結果を表示し、この意味ですか?
pure()
とpure (+1)
は何も印刷しません。
「インスタンス適用IO」が実現しました。したがって、 'pure 1 >> = \ it - >それを印刷することもできます。私は 'Text.Show.Functions'モジュールについて知りました。私はいつも関数がデフォルトで表示できないのかどうか疑問に思ってきました。 – gawi
Applicative、Functor、IOを使用したもう1つの例です: 'pure(+1)<*> fmap(read :: String - > Int)getLine' – nponeccop