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

Safe HaskellNone
LanguageHaskell2010

Language.Javascript.JSaddle.Types

Contents

Description

 
Synopsis

JavaScript Context

type 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.

The JSM Monad

type JSM = IO Source #

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

type MonadJSM = MonadIO Source #

The MonadJSM is to JSM what MonadIO is to IO. When using GHCJS it is MonadIO.

liftJSM :: MonadJSM m => JSM a -> m a Source #

The liftJSM is to JSM what liftIO is to IO. When using GHCJS it is liftIO.

Pure GHCJS functions

type GHCJSPure a = a Source #

Type we can give to functions that are pure when using ghcjs, but live in JSM when using jsaddle.

Some functions that can be pure in GHCJS cannot be implemented in a pure way in JSaddle (because we need to know the JSContextRef). Instead we implement versions of these functions in that return `GHCJSPure a` instead of a. To call them in a way that will work when compiling with GHCJS use ghcjsPure.

ghcjsPure :: GHCJSPure a -> JSM a Source #

Used when you want to call a functions that is pure in GHCJS, but lives in the JSM in jsaddle.

ghcjsPureMap :: (a -> b) -> GHCJSPure a -> GHCJSPure b Source #

JavaScript Value Types

data JSVal Source #

Instances
ToJSVal JSCallAsFunction Source #

A callback to Haskell can be used as a JavaScript value. This will create an anonymous JavaScript function object. Use function to create one with a name.

Instance details

Defined in Language.Javascript.JSaddle.Object

MakeArgs JSVal Source #

A single JSVal can be used as the argument list

Instance details

Defined in Language.Javascript.JSaddle.Value

Methods

makeArgs :: JSVal -> JSM [JSVal] Source #

MakeArgs JSCallAsFunction Source # 
Instance details

Defined in Language.Javascript.JSaddle.Object

MakeObject JSVal Source # 
Instance details

Defined in Language.Javascript.JSaddle.Value

class IsJSVal a Source #

Instances
IsJSVal Object 
Instance details

Defined in JavaScript.Object.Internal

Methods

jsval_ :: Object -> JSVal

IsJSVal JSString 
Instance details

Defined in Data.JSString.Internal.Type

Methods

jsval_ :: JSString -> JSVal

IsJSVal (Callback a) 
Instance details

Defined in GHCJS.Foreign.Callback.Internal

Methods

jsval_ :: Callback a -> JSVal

IsJSVal (SomeArrayBuffer m) 
Instance details

Defined in JavaScript.TypedArray.ArrayBuffer.Internal

Methods

jsval_ :: SomeArrayBuffer m -> JSVal

IsJSVal (SomeJSArray m) 
Instance details

Defined in JavaScript.Array.Internal

Methods

jsval_ :: SomeJSArray m -> JSVal

jsval :: IsJSVal a => a -> JSVal Source #

newtype SomeJSArray (m :: MutabilityType s) :: forall s. MutabilityType s -> Type Source #

Constructors

SomeJSArray JSVal 
Instances
IsJSVal (SomeJSArray m) 
Instance details

Defined in JavaScript.Array.Internal

Methods

jsval_ :: SomeJSArray m -> JSVal

type JSArray = SomeJSArray Immutable Source #

type STJSArray (s1 :: s) = SomeJSArray (STMutable s1) Source #

newtype Object Source #

Constructors

Object JSVal 
Instances
ToJSVal Object Source # 
Instance details

Defined in Language.Javascript.JSaddle.Value

IsJSVal Object 
Instance details

Defined in JavaScript.Object.Internal

Methods

jsval_ :: Object -> JSVal

MakeObject Object Source #

If we already have a Object we are fine

Instance details

Defined in Language.Javascript.JSaddle.Classes.Internal

data JSString Source #

A wrapper around a JavaScript string

Instances
NFData JSString 
Instance details

Defined in Data.JSString.Internal.Type

Methods

rnf :: JSString -> () Source #

IsJSVal JSString 
Instance details

Defined in Data.JSString.Internal.Type

Methods

jsval_ :: JSString -> JSVal

FromJSString JSString Source # 
Instance details

Defined in Language.Javascript.JSaddle.Value

ToJSString JSString Source #

If we already have a JSString we are fine

Instance details

Defined in Language.Javascript.JSaddle.Value

type Item JSString 
Instance details

Defined in Data.JSString

newtype Nullable a Source #

Constructors

Nullable JSVal 

type JSCallAsFunction Source #

Arguments

 = JSVal

Function object

-> JSVal

this

-> [JSVal]

Function arguments

-> JSM ()

Only () (aka JSUndefined) can be returned because the function may need to be executed in a different thread. If you need to get a value out pass in a continuation function as an argument and invoke it from haskell.

Type used for Haskell functions called from JavaScript.

Debugging

type JSadddleHasCallStack = (() :: Constraint) Source #

Like HasCallStack, but only when jsaddle cabal flag check-unchecked is set

Sync 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