miso-1.8.1.0: A tasty Haskell front-end framework
Copyright(C) 2016-2018 David M. Johnson
LicenseBSD3-style (see the file LICENSE)
MaintainerDavid M. Johnson <djohnson.m@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Miso.FFI

Description

 
Synopsis

Documentation

data JSM a #

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

Instances

Instances details
Monad JSM 
Instance details

Defined in Language.Javascript.JSaddle.Types

Methods

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

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

return :: a -> JSM a #

Functor JSM 
Instance details

Defined in Language.Javascript.JSaddle.Types

Methods

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

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

MonadFix JSM 
Instance details

Defined in Language.Javascript.JSaddle.Types

Methods

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

MonadFail JSM 
Instance details

Defined in Language.Javascript.JSaddle.Types

Methods

fail :: String -> JSM a #

Applicative JSM 
Instance details

Defined in Language.Javascript.JSaddle.Types

Methods

pure :: a -> JSM a #

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

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

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

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

MonadIO JSM 
Instance details

Defined in Language.Javascript.JSaddle.Types

Methods

liftIO :: IO a -> JSM a #

MonadThrow JSM 
Instance details

Defined in Language.Javascript.JSaddle.Types

Methods

throwM :: Exception e => e -> JSM a #

MonadCatch JSM 
Instance details

Defined in Language.Javascript.JSaddle.Types

Methods

catch :: Exception e => JSM a -> (e -> JSM a) -> JSM a #

MonadMask JSM 
Instance details

Defined in Language.Javascript.JSaddle.Types

Methods

mask :: ((forall a. JSM a -> JSM a) -> JSM b) -> JSM b #

uninterruptibleMask :: ((forall a. JSM a -> JSM a) -> JSM b) -> JSM b #

generalBracket :: JSM a -> (a -> ExitCase b -> JSM c) -> (a -> JSM b) -> JSM (b, c) #

MonadJSM JSM 
Instance details

Defined in Language.Javascript.JSaddle.Types

Methods

liftJSM' :: JSM a -> JSM a #

MonadRef JSM 
Instance details

Defined in Language.Javascript.JSaddle.Types

Associated Types

type Ref JSM :: Type -> Type #

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 
Instance details

Defined in Language.Javascript.JSaddle.Types

Methods

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

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

MonadUnliftIO JSM 
Instance details

Defined in Language.Javascript.JSaddle.Types

Methods

withRunInIO :: ((forall a. JSM a -> IO a) -> IO b) -> JSM b #

MakeArgs arg => MakeArgs (JSM arg) 
Instance details

Defined in Language.Javascript.JSaddle.Classes.Internal

Methods

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

type Ref JSM 
Instance details

Defined in Language.Javascript.JSaddle.Types

type Ref JSM = Ref IO

forkJSM :: JSM () -> JSM () Source #

Run given JSM action asynchronously, in a separate thread.

asyncCallback :: JSM () -> JSM Function Source #

Creates an asynchronous callback function

asyncCallback1 :: (JSVal -> JSM ()) -> JSM Function Source #

Creates an asynchronous callback function with a single argument

callbackToJSVal :: Function -> JSM JSVal Source #

Convert a Callback into a JSVal

objectToJSVal :: Object -> JSM JSVal Source #

Convert an Object into a JSVal

ghcjsPure :: GHCJSPure a -> JSM a #

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

syncPoint :: JSM () #

Forces execution of pending asyncronous code

addEventListener Source #

Arguments

:: JSVal

Event target on which we want to register event listener

-> MisoString

Type of event to listen to (e.g. "click")

-> (JSVal -> JSM ())

Callback which will be called when the event occurs, the event will be passed to it as a parameter.

-> JSM () 

Register an event listener on given target.

windowAddEventListener Source #

Arguments

:: MisoString

Type of event to listen to (e.g. "click")

-> (JSVal -> JSM ())

Callback which will be called when the event occurs, the event will be passed to it as a parameter.

-> JSM () 

Registers an event listener on window

windowInnerHeight :: JSM Int Source #

Retrieves the height (in pixels) of the browser window viewport including, if rendered, the horizontal scrollbar.

See https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight

windowInnerWidth :: JSM Int Source #

Retrieves the width (in pixels) of the browser window viewport including, if rendered, the vertical scrollbar.

See https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth

eventPreventDefault :: JSVal -> JSM () Source #

Prevent default event behavior

eventStopPropagation :: JSVal -> JSM () Source #

Stop propagation of events

consoleLogJSVal :: JSVal -> JSM () Source #

Console-logging

stringify :: ToJSON json => json -> JSM MisoString Source #

Converts a JS object into a JSON string

parse :: FromJSON json => JSVal -> JSM json Source #

Parses a MisoString

clearBody :: JSM () Source #

Clear the document body. This is particularly useful to avoid creating multiple copies of your app when running in GHCJSi.

objectToJSON Source #

Arguments

:: JSVal

decodeAt :: [JSString]

-> JSVal

object with impure references to the DOM

-> JSM JSVal 

Convert a JavaScript object to JSON

set :: ToJSVal v => MisoString -> v -> Object -> JSM () Source #

Set property on object

getElementById :: MisoString -> JSM JSVal Source #

Returns an Element object representing the element whose id property matches the specified string.

See https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById

diff' Source #

Arguments

:: Object

current object

-> Object

new object

-> JSVal

parent node

-> JSVal

document

-> JSM () 

Diff two virtual DOMs

integralToJSString :: Integral a => a -> MisoString Source #

Helper function for converting Integral types to JavaScript strings

realFloatToJSString :: RealFloat a => a -> MisoString Source #

Helper function for converting RealFloat types to JavaScript strings

jsStringToDouble :: MisoString -> Double Source #

Helper function for converting RealFloat types to JavaScript strings

delegateEvent :: JSVal -> JSVal -> JSM JSVal -> JSM () Source #

Initialize event delegation from a mount point.

copyDOMIntoVTree :: Bool -> JSVal -> JSVal -> JSM () Source #

Copies DOM pointers into virtual dom entry point into isomorphic javascript

swapCallbacks :: JSM () Source #

Pins down the current callbacks for clearing later

releaseCallbacks :: JSM () Source #

Releases callbacks registered by the virtual DOM.

registerCallback :: JSVal -> JSM () Source #

Mock for callback registration

focus :: MisoString -> JSM () Source #

Fails silently if the element is not found.

Analogous to document.getElementById(id).focus().

blur :: MisoString -> JSM () Source #

Fails silently if the element is not found.

Analogous to document.getElementById(id).blur()

scrollIntoView :: MisoString -> JSM () Source #

Calls document.getElementById(id).scrollIntoView()

alert :: MisoString -> JSM () Source #

Calls the alert() function.