haskellghctype-theory

What is the difference between IO a and IO (a) in Haskell?


What is the difference between IO (a) and IO a in Haskell?

For instance:

IO (String) vs IO String

IO (Int) vs IO Int

Most books I've seen wrap a type in parentheses before putting it after IO, but it's not obvious to me whether these are the same thing or not.


Solution

  • There is no difference that would matter to the compiler.

    Generally in Haskell, we like to avoid any unnecessary parentheses, so IO String is the preferred style. But of course you do need parens for e.g. IO (Maybe Int).