You can't define RealWorld, though, nor (IIRC) is IO really a state monad.
You cannot, so far as I know, implement `>>=` for the IO type defined in the above link within Haskell, which means you can't actually use it to do IO.
newtype IO a = IO ((a -> IOResult) -> IOResult) data IOResult = Hugs_ExitWith Int | Hugs_Catch IOResult (Exception -> IOResult) (Obj -> IOResult) | Hugs_ForkThread IOResult IOResult | Hugs_DeadThread | Hugs_YieldThread IOResult | Hugs_Return Obj | Hugs_BlockThread (Obj -> IOResult) ((Obj -> IOResult) -> IOResult)