Safe Haskell | None |
---|---|
Language | GHC2021 |
Language.Javascript.JSaddle.Wasm.TH
Description
Utilities for evaluating (at runtime) JS code that is known at compile time
via TemplateHaskell without relying on JS eval
.
For niche use cases, generating JSaddle-based eval
instead is
possible by disabling the eval-via-jsffi
Cabal flag.
For convenience, on non-Wasm GHCs, the semantics of having eval-via-jsffi
disabled are used.
Documentation
eval :: String -> Q Exp Source #
Generate an expression that, when called, evaluates the given chunk of JS code. Additionally, a list of argument types can be specified.
For example,
$(eval "console.log('hi')") :: JSM ()
will print "hi" to the console when executed.
Internally, this generates the following code:
- If the Cabal flag
eval-via-jsffi
is enabled (the default): An appropriate safe Wasm JSFFI import. - If
eval-via-jsffi
is disabled: Use JSaddle'seval
.