hs-duktape-0.1.5: Haskell bindings for a very compact embedded ECMAScript (JavaScript) engine.

Safe HaskellNone
LanguageHaskell2010

Scripting.Duktape

Description

Haskell bindings for duktape, a very compact embedded ECMAScript (JavaScript) engine.

Concurrency note: you can't execute code with the same context from multiple threads in parallel. If you use the same context from multiple threads, only one will run at a time, others will block.

Synopsis

Documentation

createDuktapeCtx :: MonadIO μ => μ (Maybe DuktapeCtx) Source #

Creates a Duktape context.

evalDuktape :: MonadIO μ => DuktapeCtx -> ByteString -> μ (Either String (Maybe Value)) Source #

Evaluates a string of ECMAScript on a given Duktape context.

Note: a top level object, like {some: thing}, is not a valid string to evaluate. You'd need to at least wrap it in parens, like ({some: thing}).

callDuktape Source #

Arguments

:: MonadIO μ 
=> DuktapeCtx 
-> Maybe ByteString

The name of the object that contains the function (Nothing is the global object)

-> ByteString

The function name

-> [Value]

The arguments

-> μ (Either String (Maybe Value)) 

Calls an ECMAScript function on a given Duktape context, passing in arguments from the Haskell world.

exposeFnDuktape Source #

Arguments

:: (MonadIO μ, Duktapeable ξ) 
=> DuktapeCtx 
-> Maybe ByteString

The name of the object that will contain the function (Nothing is the global object)

-> ByteString

The function name

-> ξ

The function itself

-> μ (Either String ()) 

Makes a Haskell function available in ECMAScript.

class Duktapeable ξ Source #

Minimal complete definition

runInDuktape, argCount