jsaddle-0.9.2.0: Interface for JavaScript that works with GHCJS and GHC

Safe HaskellNone
LanguageHaskell2010

Language.Javascript.JSaddle.Run

Contents

Description

 

Synopsis

Running JSM

syncPoint :: JSM () Source #

Forces execution of pending asyncronous code

syncAfter :: JSM a -> JSM a Source #

Forces execution of pending asyncronous code after performing f

waitForAnimationFrame :: JSM Double Source #

On GHCJS this is waitForAnimationFrame. On GHC it will delay the execution of the current batch of asynchronous command when they are sent to JavaScript. It will not delay the Haskell code execution. The time returned will be based on the Haskell clock (not the JavaScript clock).

nextAnimationFrame :: (Double -> JSM a) -> JSM a Source #

Tries to executes the given code in the next animation frame callback. Avoid synchronous opperations where possible.

enableLogging :: Bool -> JSM () Source #

Enable (or disable) JSaddle logging

Functions used to implement JSaddle using JSON messaging

runJavaScript :: (Batch -> IO ()) -> JSM () -> IO (Results -> IO (), Results -> IO Batch, IO ()) Source #

data AsyncCommand Source #

Command sent to a JavaScript context for execution asynchronously

Instances

Show AsyncCommand Source # 
Generic AsyncCommand Source # 

Associated Types

type Rep AsyncCommand :: * -> * #

ToJSON AsyncCommand Source # 
FromJSON AsyncCommand Source # 
NFData AsyncCommand Source # 

Methods

rnf :: AsyncCommand -> () #

type Rep AsyncCommand Source # 
type Rep AsyncCommand = D1 (MetaData "AsyncCommand" "Language.Javascript.JSaddle.Types" "jsaddle-0.9.2.0-KqbGRf9FNchAIkxhuYiMoy" False) ((:+:) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "FreeRef" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))) (C1 (MetaCons "SetPropertyByName" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSObjectForSend)) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSStringForSend)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend)))))) ((:+:) (C1 (MetaCons "SetPropertyAtIndex" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSObjectForSend)) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))))) (C1 (MetaCons "StringToValue" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSStringForSend)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend)))))) ((:+:) ((:+:) (C1 (MetaCons "NumberToValue" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Double)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend)))) (C1 (MetaCons "JSONValueToValue" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Value)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))))) ((:+:) (C1 (MetaCons "GetPropertyByName" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSObjectForSend)) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSStringForSend)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))))) ((:+:) (C1 (MetaCons "GetPropertyAtIndex" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSObjectForSend)) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))))) (C1 (MetaCons "CallAsFunction" PrefixI False) ((:*:) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSObjectForSend)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSObjectForSend))) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [JSValueForSend])) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))))))))) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "CallAsConstructor" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSObjectForSend)) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [JSValueForSend])) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))))) (C1 (MetaCons "NewEmptyObject" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend)))) ((:+:) (C1 (MetaCons "NewAsyncCallback" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))) (C1 (MetaCons "NewSyncCallback" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))))) ((:+:) ((:+:) (C1 (MetaCons "NewArray" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [JSValueForSend])) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend)))) (C1 (MetaCons "EvaluateScript" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSStringForSend)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))))) ((:+:) (C1 (MetaCons "SyncWithAnimationFrame" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))) ((:+:) (C1 (MetaCons "StartSyncBlock" PrefixI False) U1) (C1 (MetaCons "EndSyncBlock" PrefixI False) U1))))))

data Command Source #

Command sent to a JavaScript context for execution synchronously

Instances

Show Command Source # 
Generic Command Source # 

Associated Types

type Rep Command :: * -> * #

Methods

from :: Command -> Rep Command x #

to :: Rep Command x -> Command #

ToJSON Command Source # 
FromJSON Command Source # 
NFData Command Source # 

Methods

rnf :: Command -> () #

type Rep Command Source # 
type Rep Command = D1 (MetaData "Command" "Language.Javascript.JSaddle.Types" "jsaddle-0.9.2.0-KqbGRf9FNchAIkxhuYiMoy" False) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "DeRefVal" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))) ((:+:) (C1 (MetaCons "ValueToBool" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))) (C1 (MetaCons "ValueToNumber" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))))) ((:+:) (C1 (MetaCons "ValueToString" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))) ((:+:) (C1 (MetaCons "ValueToJSON" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))) (C1 (MetaCons "ValueToJSONValue" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend)))))) ((:+:) ((:+:) (C1 (MetaCons "IsNull" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))) ((:+:) (C1 (MetaCons "IsUndefined" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend))) (C1 (MetaCons "StrictEqual" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend)))))) ((:+:) (C1 (MetaCons "InstanceOf" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueForSend)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSObjectForSend)))) ((:+:) (C1 (MetaCons "PropertyNames" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSObjectForSend))) (C1 (MetaCons "Sync" PrefixI False) U1)))))

data Result Source #

Result of a Command returned from the JavaScript context

Instances

Show Result Source # 
Generic Result Source # 

Associated Types

type Rep Result :: * -> * #

Methods

from :: Result -> Rep Result x #

to :: Rep Result x -> Result #

ToJSON Result Source # 
FromJSON Result Source # 
type Rep Result Source # 
type Rep Result = D1 (MetaData "Result" "Language.Javascript.JSaddle.Types" "jsaddle-0.9.2.0-KqbGRf9FNchAIkxhuYiMoy" False) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "DeRefValResult" PrefixI False) ((:*:) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueRef)) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text)))) ((:+:) (C1 (MetaCons "ValueToBoolResult" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool))) (C1 (MetaCons "ValueToNumberResult" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Double))))) ((:+:) (C1 (MetaCons "ValueToStringResult" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSStringReceived))) ((:+:) (C1 (MetaCons "ValueToJSONResult" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSStringReceived))) (C1 (MetaCons "ValueToJSONValueResult" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Value)))))) ((:+:) ((:+:) (C1 (MetaCons "IsNullResult" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool))) ((:+:) (C1 (MetaCons "IsUndefinedResult" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool))) (C1 (MetaCons "StrictEqualResult" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool))))) ((:+:) ((:+:) (C1 (MetaCons "InstanceOfResult" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool))) (C1 (MetaCons "PropertyNamesResult" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [JSStringReceived])))) ((:+:) (C1 (MetaCons "ThrowJSValue" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 JSValueReceived))) (C1 (MetaCons "SyncResult" PrefixI False) U1)))))