Safe Haskell | None |
---|---|
Language | Haskell2010 |
JSM monad keeps track of the JavaScript context
- type JSM = ReaderT JSContextRef IO
- type JSContextRef = Ptr OpaqueJSContext
- runJSaddle :: WebView -> JSM a -> IO a
- catchval :: (MutableJSArray -> JSM a) -> (JSVal -> JSM a) -> JSM a
- catch :: (MonadIO m, Exception e) => ReaderT r IO b -> (e -> ReaderT r IO b) -> ReaderT r m b
- bracket :: MonadIO m => ReaderT r IO a -> (a -> ReaderT r IO b) -> (a -> ReaderT r IO c) -> ReaderT r m c
- postGUIAsyncJS :: JSM () -> JSM ()
- postGUISyncJS :: JSM a -> JSM a
Types
type JSM = ReaderT JSContextRef IO Source
The JSM
monad keeps track of the JavaScript context.
Given a JSM
function and a JSContextRef
you can run the
function like this...
runReaderT jsmFunction javaScriptContext
For an example of how to set up WebKitGTK+ see tests/TestJSaddle.hs
type JSContextRef = Ptr OpaqueJSContext
Running JSaddle given a DOM Window
runJSaddle :: WebView -> JSM a -> IO a Source
Exception Handling
catchval :: (MutableJSArray -> JSM a) -> (JSVal -> JSM a) -> JSM a Source
Handle JavaScriptCore functions that take a MutableJSArray in order to throw exceptions.
catch :: (MonadIO m, Exception e) => ReaderT r IO b -> (e -> ReaderT r IO b) -> ReaderT r m b Source
bracket :: MonadIO m => ReaderT r IO a -> (a -> ReaderT r IO b) -> (a -> ReaderT r IO c) -> ReaderT r m c Source
GUI thread support
postGUIAsyncJS :: JSM () -> JSM () Source
postGUISyncJS :: JSM a -> JSM a Source