/jetski

Runtime compilation and invocation of C.

Primary LanguageHaskellBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

jetski

Floats on the sea.

jetski

Overview

jetski is a library which allows for runtime compilation and execution of C code.

takeoff

Example

source :: Text
source =
  T.unlines [
      "double mean(double sum, double count) {"
    , "    return sum / count;"
    , "}"
    , ""
    , "double max(double x, double y) {"
    , "    return x > y ? x : y;"
    , "}"
    ]

mean :: Double -> Double -> IO (Either JetskiError Double)
mean sum count =
  runEitherT $ withLibrary [] source $ \library -> do
    mean <- function library "mean" retDouble
    mean [argDouble sum, argDouble count]

barrel-flip