Is the IO type built-in?

Huh, I wasn’t aware that data declarations don’t need a right-hand side.

If they did…it would make defining another abstract Haskell type rather “interesting” :

data (->) a b = ... {- ??? -}

…and for the same reason: just like I/O actions, the way ordinary Haskell functions can be constructed is invariably specific to each Haskell implementation.

As I mentioned here:

no-one seems to be mystified by how a type like (->) a b - whose expressions have no (externally-visible) effects - can be implemented in thoroughly-imperative effect-centric assembly code.

IO a is another one of Haskell’s types which happens to be defined abstractly…since 1996 (when the Haskell 1.3 report was published).

2 Likes