Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data JSContextRef = JSContextRef {
- startTime :: UTCTime
- doSendCommand :: Command -> IO Result
- doSendAsyncCommand :: AsyncCommand -> IO ()
- addCallback :: Object -> JSCallAsFunction -> IO ()
- freeCallback :: Object -> IO ()
- nextRef :: TVar JSValueRef
- newtype JSM a = JSM {
- unJSM :: ReaderT JSContextRef IO a
- class (Applicative m, MonadIO m) => MonadJSM m where
- liftJSM :: MonadJSM m => JSM a -> m a
- newtype JSVal = JSVal JSValueRef
- newtype MutableJSArray = MutableJSArray JSValueRef
- newtype Object = Object JSVal
- newtype JSString = JSString Text
- newtype Nullable a = Nullable a
- type JSCallAsFunction = JSVal -> JSVal -> [JSVal] -> JSM ()
- newtype JSValueReceived = JSValueReceived JSValueRef
- newtype JSValueForSend = JSValueForSend JSValueRef
- newtype JSStringReceived = JSStringReceived Text
- newtype JSStringForSend = JSStringForSend Text
- newtype JSObjectForSend = JSObjectForSend JSValueForSend
- data AsyncCommand
- = FreeRef JSValueForSend
- | SetPropertyByName JSObjectForSend JSStringForSend JSValueForSend
- | SetPropertyAtIndex JSObjectForSend Int JSValueForSend
- | StringToValue JSStringForSend JSValueForSend
- | NumberToValue Double JSValueForSend
- | GetPropertyByName JSObjectForSend JSStringForSend JSValueForSend
- | GetPropertyAtIndex JSObjectForSend Int JSValueForSend
- | CallAsFunction JSObjectForSend JSObjectForSend [JSValueForSend] JSValueForSend
- | CallAsConstructor JSObjectForSend [JSValueForSend] JSValueForSend
- | NewEmptyObject JSValueForSend
- | NewCallback JSValueForSend
- | NewArray [JSValueForSend] JSValueForSend
- | EvaluateScript JSStringForSend JSValueForSend
- | SyncWithAnimationFrame JSValueForSend
- data Command
- = DeRefVal JSValueForSend
- | ValueToBool JSValueForSend
- | ValueToNumber JSValueForSend
- | ValueToString JSValueForSend
- | ValueToJSON JSValueForSend
- | IsNull JSValueForSend
- | IsUndefined JSValueForSend
- | StrictEqual JSValueForSend JSValueForSend
- | InstanceOf JSValueForSend JSObjectForSend
- | PropertyNames JSObjectForSend
- | Sync
- data Batch = Batch [AsyncCommand] Command Bool
- data Result
- = DeRefValResult JSValueRef Text
- | ValueToBoolResult Bool
- | ValueToNumberResult Double
- | ValueToStringResult JSStringReceived
- | ValueToJSONResult JSStringReceived
- | IsNullResult Bool
- | IsUndefinedResult Bool
- | StrictEqualResult Bool
- | InstanceOfResult Bool
- | Callback JSValueReceived JSValueReceived [JSValueReceived]
- | PropertyNamesResult [JSStringReceived]
- | ThrowJSValue JSValueReceived
- | ProtocolError Text
- | SyncResult
JavaScript Context
data JSContextRef Source #
Identifies a JavaScript execution context. When using GHCJS this is just '()' since their is only one context. When using GHC it includes the functions JSaddle needs to communicate with the JavaScript context.
JSContextRef | |
|
The JSM Monad
The JSM
monad keeps track of the JavaScript execution context.
When using GHCJS it is IO
.
Given a JSM
function and a JSContextRef
you can run the
function like this...
runJSM jsmFunction javaScriptContext
JSM | |
|
class (Applicative m, MonadIO m) => MonadJSM m where Source #
JavaScript Value Types
See Object
See Type
type JSCallAsFunction Source #
= JSVal | Function object |
-> JSVal | this |
-> [JSVal] | Function arguments |
-> JSM () | Only () (aka |
Type used for Haskell functions called from JavaScript.
JavaScript Context Commands
newtype JSValueReceived Source #
Wrapper used when receiving a JSVal
from the JavaScript context
JSValueReceived JSValueRef |
newtype JSValueForSend Source #
Wrapper used when sending a JSVal
to the JavaScript context
JSValueForSend JSValueRef |
newtype JSStringReceived Source #
Wrapper used when receiving a JSString
from the JavaScript context
newtype JSStringForSend Source #
Wrapper used when sending a JString
to the JavaScript context
newtype JSObjectForSend Source #
Wrapper used when sending a Object
to the JavaScript context
data AsyncCommand Source #
Command sent to a JavaScript context for execution asynchronously
Command sent to a JavaScript context for execution synchronously
Batch of commands that can be sent together to the JavaScript context
Result of a Command
returned from the JavaScript context