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

Safe HaskellNone
LanguageHaskell2010

Language.Javascript.JSaddle.Types

Contents

Description

 

Synopsis

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.

The JSM Monad

newtype JSM a 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

Constructors

JSM 

Instances

Monad JSM Source # 

Methods

(>>=) :: JSM a -> (a -> JSM b) -> JSM b #

(>>) :: JSM a -> JSM b -> JSM b #

return :: a -> JSM a #

fail :: String -> JSM a #

Functor JSM Source # 

Methods

fmap :: (a -> b) -> JSM a -> JSM b #

(<$) :: a -> JSM b -> JSM a #

MonadFix JSM Source # 

Methods

mfix :: (a -> JSM a) -> JSM a #

Applicative JSM Source # 

Methods

pure :: a -> JSM a #

(<*>) :: JSM (a -> b) -> JSM a -> JSM b #

(*>) :: JSM a -> JSM b -> JSM b #

(<*) :: JSM a -> JSM b -> JSM a #

MonadIO JSM Source # 

Methods

liftIO :: IO a -> JSM a #

MonadRef JSM Source # 

Associated Types

type Ref (JSM :: * -> *) :: * -> * #

Methods

newRef :: a -> JSM (Ref JSM a) #

readRef :: Ref JSM a -> JSM a #

writeRef :: Ref JSM a -> a -> JSM () #

modifyRef :: Ref JSM a -> (a -> a) -> JSM () #

modifyRef' :: Ref JSM a -> (a -> a) -> JSM () #

MonadAtomicRef JSM Source # 

Methods

atomicModifyRef :: Ref JSM a -> (a -> (a, b)) -> JSM b #

atomicModifyRef' :: Ref JSM a -> (a -> (a, b)) -> JSM b #

MonadJSM JSM Source # 

Methods

liftJSM' :: JSM a -> JSM a Source #

MakeArgs arg => MakeArgs (JSM arg) Source # 

Methods

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

type Ref JSM Source # 
type Ref JSM = Ref IO

class (Applicative m, MonadIO m) => MonadJSM m where Source #

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

Methods

liftJSM' :: JSM a -> m a Source #

liftJSM' :: (MonadJSM m', MonadTrans t) => JSM a' -> t m' a' Source #

Instances

MonadJSM JSM Source # 

Methods

liftJSM' :: JSM a -> JSM a Source #

MonadJSM m => MonadJSM (ListT m) Source # 

Methods

liftJSM' :: JSM a -> ListT m a Source #

MonadJSM m => MonadJSM (MaybeT m) Source # 

Methods

liftJSM' :: JSM a -> MaybeT m a Source #

MonadJSM m => MonadJSM (IdentityT * m) Source # 

Methods

liftJSM' :: JSM a -> IdentityT * m a Source #

(Error e, MonadJSM m) => MonadJSM (ErrorT e m) Source # 

Methods

liftJSM' :: JSM a -> ErrorT e m a Source #

MonadJSM m => MonadJSM (ExceptT e m) Source # 

Methods

liftJSM' :: JSM a -> ExceptT e m a Source #

MonadJSM m => MonadJSM (StateT s m) Source # 

Methods

liftJSM' :: JSM a -> StateT s m a Source #

MonadJSM m => MonadJSM (StateT s m) Source # 

Methods

liftJSM' :: JSM a -> StateT s m a Source #

(Monoid w, MonadJSM m) => MonadJSM (WriterT w m) Source # 

Methods

liftJSM' :: JSM a -> WriterT w m a Source #

(Monoid w, MonadJSM m) => MonadJSM (WriterT w m) Source # 

Methods

liftJSM' :: JSM a -> WriterT w m a Source #

MonadJSM m => MonadJSM (ContT * r m) Source # 

Methods

liftJSM' :: JSM a -> ContT * r m a Source #

MonadJSM m => MonadJSM (ReaderT * r m) Source # 

Methods

liftJSM' :: JSM a -> ReaderT * r m a Source #

(Monoid w, MonadJSM m) => MonadJSM (RWST r w s m) Source # 

Methods

liftJSM' :: JSM a -> RWST r w s m a Source #

(Monoid w, MonadJSM m) => MonadJSM (RWST r w s m) Source # 

Methods

liftJSM' :: JSM a -> RWST r w s m a Source #

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

newtype GHCJSPure 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.

Constructors

GHCJSPure (JSM a) 

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

newtype SomeJSArray m Source #

Constructors

SomeJSArray JSVal 

Instances

newtype JSString Source #

A wrapper around a JavaScript string

Constructors

JSString Text 

Instances

Eq JSString Source # 
Data JSString Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> JSString -> c JSString #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c JSString #

toConstr :: JSString -> Constr #

dataTypeOf :: JSString -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c JSString) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c JSString) #

gmapT :: (forall b. Data b => b -> b) -> JSString -> JSString #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> JSString -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> JSString -> r #

gmapQ :: (forall d. Data d => d -> u) -> JSString -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> JSString -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> JSString -> m JSString #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> JSString -> m JSString #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> JSString -> m JSString #

Ord JSString Source # 
Read JSString Source # 
Show JSString Source # 
IsString JSString Source # 
Monoid JSString Source # 
ToJSON JSString Source # 
FromJSON JSString Source # 
NFData JSString Source # 

Methods

rnf :: JSString -> () #

type Item JSString # 

newtype Nullable a Source #

Constructors

Nullable a 

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

JavaScript Context Commands

data MutabilityType s Source #

Constructors

Mutable_ s 
Immutable_ s 
STMutable s 

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 Batch Source #

Batch of commands that can be sent together to the JavaScript context

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)))))

data Results Source #

Instances

Show Results Source # 
Generic Results Source # 

Associated Types

type Rep Results :: * -> * #

Methods

from :: Results -> Rep Results x #

to :: Rep Results x -> Results #

ToJSON Results Source # 
FromJSON Results Source # 
type Rep Results Source #