Last active
December 27, 2015 10:09
-
-
Save robstewart57/7309396 to your computer and use it in GitHub Desktop.
Using values that are not first class in LLVM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Data.Int | |
import LLVM.Core | |
import LLVM.ExecutionEngine | |
notFirstClass :: CodeGenModule (Function ([Int8] -> IO [Int8])) | |
notFirstClass = do | |
test <- createNamedFunction ExternalLinkage "test" $ \x -> do | |
ret x | |
let _ = test :: Function ([Int8] -> IO [Int8]) | |
return test | |
main :: IO () | |
main = do | |
initializeNativeTarget | |
xs <- simpleFunction notFirstClass | |
xs [1,2,3] >>= print | |
{- ERROR | |
NotFirstClass.hs:10:13: | |
No instance for (IsFirstClass [Int8]) | |
arising from a use of `createNamedFunction' | |
Possible fix: add an instance declaration for (IsFirstClass [Int8]) | |
In the expression: createNamedFunction ExternalLinkage "test" | |
In a stmt of a 'do' block: | |
test <- createNamedFunction ExternalLinkage "test" | |
$ \ x -> do { ret x } | |
In the expression: | |
do { test <- createNamedFunction ExternalLinkage "test" | |
$ \ x -> do { ... }; | |
let _ = ...; | |
return test } | |
NotFirstClass.hs:19:11: | |
No instance for (Generic [Int8]) | |
arising from a use of `simpleFunction' | |
Possible fix: add an instance declaration for (Generic [Int8]) | |
In a stmt of a 'do' block: xs <- simpleFunction notFirstClass | |
In the expression: | |
do { initializeNativeTarget; | |
xs <- simpleFunction notFirstClass; | |
xs [1, 2, ....] >>= print } | |
In an equation for `main': | |
main | |
= do { initializeNativeTarget; | |
xs <- simpleFunction notFirstClass; | |
xs [1, ....] >>= print } | |
Failed, modules loaded: none. | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment