Skip to content

Instantly share code, notes, and snippets.

@mmn80
Created April 22, 2017 15:17
Show Gist options
  • Save mmn80/387eb7a335da6160f52d39ce02881bd4 to your computer and use it in GitHub Desktop.
Save mmn80/387eb7a335da6160f52d39ce02881bd4 to your computer and use it in GitHub Desktop.
Export control
module CPP
import System
%language ElabReflection
%language TypeProviders
export
testFn : Int -> String
testFn x = "testFn: " ++ show x
mkName : IO (Provider String)
mkName = do
Right v <- readFile "version.txt" | Left e => pure (Error $ show e)
--Just v <- getEnv "PATH" | _ => pure (Error "ERR")
pure (Provide $ "testFn_v" ++ (trim v))
%provide (fnName : String) with mkName
mkFnName : Elab ()
mkFnName = do
fill (RConstant fnName)
solve
exports : FFI_Export FFI_C "exports.h" []
exports = Fun testFn (%runElab mkFnName) $ End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment