Go to the first, previous, next, last section, table of contents.

Using your own `mainPrimIO'

Normally, the GHC runtime system begins things by called an internal function `mainPrimIO :: PrimIO ()' which, in turn, fires up `dialogueToIO :: Dialogue -> IO ()', linking in your `Main.main' to provide the `Dialogue'.

(If you give a `-fhaskell-1.3' flag, then a different `mainPrimIO' will be linked in -- that's why it is important to link with `-fhaskell-1.3'...)

To subvert the above process, you need only provide a `mainPrimIO :: PrimIO ()' of your own (in a module named `Main'). Do not use a `-fhaskell-1.3' flag!

Here's a little example, stolen from Alastair Reid:

module Main ( mainPrimIO ) where

import PreludeGlaST

mainPrimIO :: PrimIO ()
mainPrimIO = 
         sleep 5                                `seqPrimIO`
         _ccall_ printf "%d\n" (14::Int)

sleep :: Int -> PrimIO ()
sleep t = _ccall_ sleep t


Go to the first, previous, next, last section, table of contents.