Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ httpGet = do
JSON req <- input
-- Send the request, get a 'Response'
res <- sendRequest req (Nothing :: Maybe String)
-- Save response body to memory
outputMemory (memory res)
-- Save response body to output
output $ responseData res
-- Return code
return 0

Expand All @@ -243,6 +243,8 @@ to do this correctly. So we recommend reading out [concept doc on Host Functions
Host functions in the Haskell PDK require C stubs to import a function from a particular namespace:

```c
#include <stdint.h>

#define IMPORT(a, b) __attribute__((import_module(a), import_name(b)))
IMPORT("extism:host/user", "a_python_func")
uint64_t a_python_func_impl(uint64_t input);
Expand All @@ -265,8 +267,9 @@ foreign import ccall "a_python_func" aPythonFunc :: Word64 -> IO Word64
helloFromPython :: String -> IO String
helloFromPython = do
s' <- allocString "Hello!"
res <- aPythonFunc (memoryOffset s')
logInfo <$> loadString res
resOffset <- aPythonFunc (memoryOffset s')
resMem <- findMemory resOffset
logInfo =<< loadString resMem
return 0

foreign export ccall "helloFromPython" helloFromPython :: IO Int32
Expand Down
Loading