[haskell-llvm] Beginner - Anonymous Functions
Elliott Pace
etp20 at cam.ac.uk
Sun Nov 6 22:16:49 GMT 2011
Hi,
I'm a beginner to using Haskell-LLVM and when trying to pull together some
toy functions, I came across the following problem. I've looked at the
examples but I cannot find something that does this.
The idea is to create a curried function (and therefore an anonymous
function) ala:
plus x y = x + y;
My attempt is as below:
data Mod = Mod { mplus :: Function (Word32 -> IO (Function (Word32 ->
IO Word32)))
}
buildMod :: CodeGenModule Mod
buildMod = do
plus <- newNamedFunction ExternalLinkage "plus"
defineFunction plus $ \x -> do
f <- createFunction PrivateLinkage $ \y -> do
res <- add (x::Word32) (y::Word32)
ret res
ret f
return $ Mod plus
but unfortunately I have the error:
Couldn't match expected type `CodeGenModule b' against inferred type
`CodeGenFunction r Terminate'
In the expression: ret f
Does anyone have any pointers to code to read/documents that could explain
what I'm doing wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://projects.haskell.org/pipermail/haskell-llvm/attachments/20111106/f8468bb8/attachment.htm>
More information about the Haskell-llvm
mailing list