What a surprise: it’s a question about I/O in Haskell - I’m assuming none of these helped. Let’s try something different and see how Agda performs I/O:
Haskell 2010 almost permits a similar "outsourcing" of I/O:
-- the I/O ADT...
data IO a
foreign import "primUnitIO" unitIO :: a -> IO a
foreign import "primBindIO" bindIO :: IO a -> (a -> IO b) -> IO b
instance Monad IO where
return = unitIO
(>>=) = bindIO
Main.main
can be dealt with in similar fashion, so:
module Main(main) where
main :: IO ()
⋮
would be translated into:
module Main() where
foreign export "hs_Main_main" main :: IO ()
main :: IO ()
⋮
So after all that, what does evaluating main
entail?
{- Haskell I/O outsourced: nothing to see here... -}
…just as Agda outsources I/O - and not a real faux world in sight! It just requires some FFI extensions. It would also help to make abundantly clear that the monadic interface is actually relatively boring e.g:
-- "alternate" I/O ADT!
data IO a
type Await a = IO a -> a
foreign import "primAsyncIO" asyncIO :: ((forall a . Await a) -> b) -> IO b
instance Monad IO where
return x = asyncIO $ \ await -> x
m >>= k = asyncIO $ \ await -> let !x = await m in
let !y = await (k x) in
y