Perform the following types:
fmap print (pure 2) :: Applicative f => f (IO ())
fmap id (pure 2) :: (Num b, Applicative f) => f b
Allows to replace fwith IO:
fmap print (pure 2) :: IO (IO ()) --
fmap id (pure 2) :: (Num b) => IO b --
Now you can clearly see that # 2 is an action with a numerical result, while # 1 is an action with another action as a result.
In addition, GHCi has the following interactive evaluation rules :
2.4. Interactive evaluation at the command line
When entering an expression at the prompt, GHCi immediately evaluates and prints the result:
2.4.1. Command Line I / O
GHCi . - IO a a, GHCi IO-.
, GHCi -, ( ):
IO a Show, -.