Skip to content

Commit 1c30925

Browse files
authored
doc: fix non-compiling examples (#20)
1 parent fae7d1e commit 1c30925

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

README.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ httpGet = do
225225
JSON req <- input
226226
-- Send the request, get a 'Response'
227227
res <- sendRequest req (Nothing :: Maybe String)
228-
-- Save response body to memory
229-
outputMemory (memory res)
228+
-- Save response body to output
229+
output $ responseData res
230230
-- Return code
231231
return 0
232232

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

250250
```c
251+
#include <stdint.h>
252+
251253
#define IMPORT(a, b) __attribute__((import_module(a), import_name(b)))
252254
IMPORT("extism:host/user", "a_python_func")
253255
uint64_t a_python_func_impl(uint64_t input);
@@ -270,8 +272,9 @@ foreign import ccall "a_python_func" aPythonFunc :: Word64 -> IO Word64
270272
helloFromPython :: String -> IO String
271273
helloFromPython = do
272274
s' <- allocString "Hello!"
273-
res <- aPythonFunc (memoryOffset s')
274-
logInfo <$> loadString res
275+
resOffset <- aPythonFunc (memoryOffset s')
276+
resMem <- findMemory resOffset
277+
logInfo =<< loadString resMem
275278
return 0
276279

277280
foreign export ccall "helloFromPython" helloFromPython :: IO Int32

0 commit comments

Comments
 (0)