IO implementation inside Haskell
问题 I know as a fact, that we cant implement an IO monad independently, but I dont know why exactly. This code is an attempt to implement an imperative paradigm using functional language. Can you explain the difference between this example and true IO? It looks like function main implements the correct action order and remains lazy. import System.IO.Unsafe data Io a = Io a runIO :: Io a -> a runIO (Io a) = a instance Monad Io where return x = Io x Io a >>= f = f a -- internal side effect function