You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This package provides a Haskell wrapper for the [QuickJS](https://bellard.org/quickjs/) library.
7
+
8
+
## Features
9
+
10
+
The functionality is quite basic and is currently limited to:
11
+
- evaluating JS code
12
+
- calling a JS function in the global scope
13
+
- marshalling [Aeson Values](https://hackage.haskell.org/package/aeson-1.5.3.0/docs/Data-Aeson.html#t:Value) to and from JSValues.
14
+
15
+
16
+
## Examples
17
+
Evaluate an expression:
18
+
19
+
```haskell
20
+
importQuickjs
21
+
22
+
one_plus_two = quickjs $do
23
+
res <- eval "1+2"
24
+
liftIO $print res
25
+
```
26
+
27
+
Declare a function and call it on an argument:
28
+
29
+
```haskell
30
+
call_f = quickjs $do
31
+
_ <- eval_ "f = (x) => x+1"
32
+
res <- eval "f(2)"
33
+
liftIO $print res
34
+
```
35
+
36
+
Pass a Haskell value (which has a [ToJSON](https://hackage.haskell.org/package/aeson-1.5.3.0/docs/Data-Aeson.html#t:ToJSON) instance) to the JS runtime:
37
+
38
+
```haskell
39
+
aeson_marshall = quickjs $do
40
+
_ <- eval_ "f = (x) => x+1"
41
+
res <- withJSValue (3::Int) $\x -> call "f" [x]
42
+
liftIO $print res
43
+
```
44
+
45
+
## Contributing
46
+
47
+
Please feel free to report bugs/submit feature requests via the [github issue tracker](https://github.com/goodlyrottenapple/quickjs-hs/issues) and submit any pull requests to the [git repository](https://github.com/goodlyrottenapple/quickjs-hs/)
0 commit comments