[haskell-llvm] [Haskell-cafe] LLVM, getElementPtr?
lemming at henning-thielemann.de
Mon Dec 6 14:07:16 EST 2010
On Mon, 6 Dec 2010, Ryan Ingram wrote:
> On Sun, Dec 5, 2010 at 12:45 PM, Lally Singh <lally.singh at gmail.com> wrote:
>> Is that how it's intended?
> I think that's correct, (it at least fits the pattern for 'with'
> functions in Haskell).
I'm glad to have chosen a name that guides people to the correct usage.
> They're idiomatically used with syntax like this:
>> buildReaderFun :: String -> CodeGenModule (Function (IO ()))
>> buildReaderFun nm = do
>> puts <- newNamedFunction ExternalLinkage "puts" :: TFunction (Ptr Word8 -> IO Word32)
>> withStringNul nm $ \greetz -> createFunction ExternalLinkage $ do
>> tmp <- getElementPtr greetz (0 :: Word32,(0 :: Word32, ()))
>> call puts tmp -- Throw away return value.
>> ret ()
Using ($) is not allowed here, since the functional parameter of
withStringNul is universally quantified. You have to write
> withStringNul nm (\greetz -> createFunction ExternalLinkage $ do
> tmp <- getElementPtr greetz (0 :: Word32,(0 :: Word32, ()))
> call puts tmp -- Throw away return value.
> ret ())
More information about the Haskell-llvm