Why this code does not compile with an Ambiguous type variable
error
foo :: (Show a) => a -> IO ()
foo = putStrLn . show
bar = foo
whereas in the GHCI the following commands work fine?
> let foo :: (Show a) => a -> IO (); foo = putStrLn . show
> bar = foo
> bar 1
Why do we need an explicit type annotation for the bar
function?