Skip to content

Instantly share code, notes, and snippets.

@robstewart57
Last active December 27, 2015 10:09

Revisions

  1. robstewart57 revised this gist Nov 4, 2013. 1 changed file with 33 additions and 0 deletions.
    33 changes: 33 additions & 0 deletions NotFirstClass.hs
    Original file line number Diff line number Diff line change
    @@ -18,3 +18,36 @@ 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.
    -}
  2. robstewart57 created this gist Nov 4, 2013.
    20 changes: 20 additions & 0 deletions NotFirstClass.hs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    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