[haskell-llvm] [Haskell-cafe] LLVM, type-level?

Henning Thielemann lemming at henning-thielemann.de
Fri Dec 10 05:42:11 EST 2010


On Thu, 9 Dec 2010, Lally Singh wrote:

> type MainFunction = Function (Int32 -> Ptr (Ptr Word8) -> IO Int32)
> buildReaderFun :: String -> CodeGenModule (MainFunction)
> buildReaderFun nm  = do
>  puts <- newNamedFunction ExternalLinkage "puts" ::
>    TFunction (Ptr Word8 -> IO Word32)
>  let callPuts format = (
>        createNamedFunction ExternalLinkage "main" $
>        \ argc argv -> do
>          tmp <- getElementPtr (argv ::Value (Ptr Word8))
>                 (0 :: Int32,  ())
>          call puts tmp -- Throw away return value.

Btw. better than a comment is certainly

_ <- call puts tmp

or

void $ call puts tmp

(However 'Control.Monad.void' is only in base>=4.3 / GHC>=6.12)

>          ret (0 :: Int32)) :: CodeGenModule (MainFunction)
>
>  withStringNul nm callPuts



More information about the Haskell-llvm mailing list