-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | High level interface for webkit-javascriptcore -- -- This package provides an EDSL for calling JavaScript code using the -- JavaScriptCore engine and low level Haskell bindings in the -- webkit-javascriptcore library -- https://github.com/ghcjs/webkit-javascriptcore. @package jsaddle @version 0.2.0.6 module Language.Javascript.JSaddle.Types type JSValueRef = Ptr OpaqueJSValue type JSValueRefRef = Ptr JSValueRef type JSObjectRef = Ptr OpaqueJSValue type JSPropertyNameArrayRef = Ptr OpaqueJSPropertyNameArray type JSPropertyAttributes = CUInt type JSContextRef = Ptr OpaqueJSContext type JSStringRef = Ptr OpaqueJSString type Index = CUInt -- | JSM monad keeps track of the JavaScript context module Language.Javascript.JSaddle.Monad -- | The JSM monad keeps track of the JavaScript context. -- -- Given a JSM function and a JSContextRef you can run -- the function like this... -- --
--   runReaderT jsmFunction javaScriptContext
--   
-- -- For an example of how to set up WebKitGTK+ see tests/TestJSaddle.hs type JSM = ReaderT JSContextRef IO type JSContextRef = Ptr OpaqueJSContext runJSaddle :: WebView -> JSM a -> IO a runJSaddle_ :: WebView -> JSM a -> IO () -- | Handle JavaScriptCore functions that take a JSValueRefRef in order to -- throw exceptions. catchval :: (JSValueRefRef -> JSM a) -> (JSValueRef -> JSM a) -> JSM a -- | Wrapped version of catch that runs in a MonadIO that works a -- bit better with JSM catch :: (MonadIO m, Exception e) => ReaderT r IO b -> (e -> ReaderT r IO b) -> ReaderT r m b module Language.Javascript.JSaddle.Exception data JSException JSException :: JSValueRef -> JSException -- | Catch JavaScript exceptions and rethrow Haskell ones rethrow :: (JSValueRefRef -> JSM a) -> JSM a instance GHC.Show.Show Language.Javascript.JSaddle.Exception.JSException instance GHC.Exception.Exception Language.Javascript.JSaddle.Exception.JSException -- | These classes are used to make various JavaScript types out of -- whatever we have. Functions in jsaddle take these as inputs. This -- alows implicit casting and eager evaluation. module Language.Javascript.JSaddle.Classes -- | Anything that can be used to make a JavaScript value reference class MakeValueRef a makeValueRef :: MakeValueRef a => a -> JSM JSValueRef -- | Anything that can be used to make a JavaScript string reference class MakeStringRef a makeStringRef :: MakeStringRef a => a -> JSStringRef -- | Anything that can be used to make a list of JavaScript value -- references for use as function arguments class MakeArgRefs this makeArgRefs :: MakeArgRefs this => this -> JSM [JSValueRef] -- | Anything that can be used to make a JavaScript object reference class MakeObjectRef this makeObjectRef :: MakeObjectRef this => this -> JSM JSObjectRef -- | Anything that can be used to make a JavaScript property reference class MakePropRef this makePropRef :: MakePropRef this => this -> JSM JSPropRef module Language.Javascript.JSaddle.Arguments -- | Anything that can be used to make a list of JavaScript value -- references for use as function arguments class MakeArgRefs this makeArgRefs :: MakeArgRefs this => this -> JSM [JSValueRef] instance Language.Javascript.JSaddle.Classes.MakeArgRefs arg => Language.Javascript.JSaddle.Classes.MakeArgRefs (Language.Javascript.JSaddle.Monad.JSM arg) instance Language.Javascript.JSaddle.Classes.MakeValueRef arg => Language.Javascript.JSaddle.Classes.MakeArgRefs [arg] instance (Language.Javascript.JSaddle.Classes.MakeValueRef arg1, Language.Javascript.JSaddle.Classes.MakeValueRef arg2) => Language.Javascript.JSaddle.Classes.MakeArgRefs (arg1, arg2) instance (Language.Javascript.JSaddle.Classes.MakeValueRef arg1, Language.Javascript.JSaddle.Classes.MakeValueRef arg2, Language.Javascript.JSaddle.Classes.MakeValueRef arg3) => Language.Javascript.JSaddle.Classes.MakeArgRefs (arg1, arg2, arg3) instance (Language.Javascript.JSaddle.Classes.MakeValueRef arg1, Language.Javascript.JSaddle.Classes.MakeValueRef arg2, Language.Javascript.JSaddle.Classes.MakeValueRef arg3, Language.Javascript.JSaddle.Classes.MakeValueRef arg4) => Language.Javascript.JSaddle.Classes.MakeArgRefs (arg1, arg2, arg3, arg4) instance (Language.Javascript.JSaddle.Classes.MakeValueRef arg1, Language.Javascript.JSaddle.Classes.MakeValueRef arg2, Language.Javascript.JSaddle.Classes.MakeValueRef arg3, Language.Javascript.JSaddle.Classes.MakeValueRef arg4, Language.Javascript.JSaddle.Classes.MakeValueRef arg5) => Language.Javascript.JSaddle.Classes.MakeArgRefs (arg1, arg2, arg3, arg4, arg5) -- | JavaScript string conversion functions module Language.Javascript.JSaddle.String type JSStringRef = Ptr OpaqueJSString -- | Anything that can be used to make a JavaScript string reference class MakeStringRef a makeStringRef :: MakeStringRef a => a -> JSStringRef -- | Convert a JavaScript string to a Haskell Text strToText :: MonadIO m => JSStringRef -> m Text -- | Convert a Haskell Text to a JavaScript string textToStr :: Text -> JSStringRef instance Language.Javascript.JSaddle.Classes.MakeStringRef Graphics.UI.Gtk.WebKit.JavaScriptCore.JSBase.JSStringRef instance Language.Javascript.JSaddle.Classes.MakeStringRef Data.Text.Internal.Text instance Language.Javascript.JSaddle.Classes.MakeStringRef GHC.Base.String -- | Deals with JavaScript values. These can be -- -- module Language.Javascript.JSaddle.Value type JSValueRef = Ptr OpaqueJSValue -- | Anything that can be used to make a JavaScript value reference class MakeValueRef a makeValueRef :: MakeValueRef a => a -> JSM JSValueRef data JSNull -- | Type that represents a value that can only be null. Haskell of course -- has no null so we are adding this type. JSNull :: JSNull type JSUndefined = () A type that can only be undefined in JavaScript. Using () because functions in JavaScript that have no return, impicitly return undefined. type JSBool = Bool JavaScript boolean values map the 'Bool' haskell type. type JSNumber = Double A number in JavaScript maps nicely to 'Double'. type JSString = Text JavaScript strings can be represented with the Haskell 'Text' type. -- | An algebraic data type that can represent a JavaScript value. Any -- JavaScriptCore JSValueRef can be converted into this type. data JSValue -- | null ValNull :: JSValue -- | undefined ValUndefined :: JSValue -- | true or false ValBool :: JSBool -> JSValue -- | a number ValNumber :: JSNumber -> JSValue -- | a string ValString :: JSString -> JSValue -- | an object ValObject :: JSObjectRef -> JSValue -- | Given a JavaScript value get its boolean value. All values in -- JavaScript convert to bool. -- --
--   >>> testJSaddle $ valToBool JSNull
--   false
--   
--   >>> testJSaddle $ valToBool ()
--   false
--   
--   >>> testJSaddle $ valToBool True
--   true
--   
--   >>> testJSaddle $ valToBool False
--   false
--   
--   >>> testJSaddle $ valToBool (1.0 :: Double)
--   true
--   
--   >>> testJSaddle $ valToBool (0.0 :: Double)
--   false
--   
--   >>> testJSaddle $ valToBool ""
--   false
--   
--   >>> testJSaddle $ valToBool "1"
--   true
--   
valToBool :: MakeValueRef val => val -> JSM JSBool -- | Given a JavaScript value get its numeric value. May throw JSException. -- --
--   >>> testJSaddle $ show <$> valToNumber JSNull
--   0.0
--   
--   >>> testJSaddle $ show <$> valToNumber ()
--   NaN
--   
--   >>> testJSaddle $ show <$> valToNumber True
--   1.0
--   
--   >>> testJSaddle $ show <$> valToNumber False
--   0.0
--   
--   >>> testJSaddle $ show <$> valToNumber (1.0 :: Double)
--   1.0
--   
--   >>> testJSaddle $ show <$> valToNumber (0.0 :: Double)
--   0.0
--   
--   >>> testJSaddle $ show <$> valToNumber ""
--   0.0
--   
--   >>> testJSaddle $ show <$> valToNumber "1"
--   1.0
--   
valToNumber :: MakeValueRef val => val -> JSM JSNumber -- | Given a JavaScript value get its string value (as a JavaScript -- string). May throw JSException. -- --
--   >>> testJSaddle $ valToStr JSNull >>= strToText
--   null
--   
--   >>> testJSaddle $ valToStr () >>= strToText
--   undefined
--   
--   >>> testJSaddle $ valToStr True >>= strToText
--   true
--   
--   >>> testJSaddle $ valToStr False >>= strToText
--   false
--   
--   >>> testJSaddle $ valToStr (1.0 :: Double) >>= strToText
--   1
--   
--   >>> testJSaddle $ valToStr (0.0 :: Double) >>= strToText
--   0
--   
--   >>> testJSaddle $ valToStr "" >>= strToText
--   
-- --
--   >>> testJSaddle $ valToStr "1" >>= strToText
--   1
--   
valToStr :: MakeValueRef val => val -> JSM JSStringRef -- | Given a JavaScript value get its object value. May throw JSException. -- --
--   >>> testJSaddle $ (valToObject JSNull >>= valToText) `catch` \ (JSException e) -> valToText e
--   TypeError: 'null' is not an object
--   
--   >>> testJSaddle $ (valToObject () >>= valToText) `catch` \ (JSException e) -> valToText e
--   TypeError: 'undefined' is not an object
--   
--   >>> testJSaddle $ valToObject True
--   true
--   
--   >>> testJSaddle $ valToObject False
--   false
--   
--   >>> testJSaddle $ valToObject (1.0 :: Double)
--   1
--   
--   >>> testJSaddle $ valToObject (0.0 :: Double)
--   0
--   
--   >>> testJSaddle $ valToObject ""
--   
-- --
--   >>> testJSaddle $ valToObject "1"
--   1
--   
valToObject :: MakeValueRef val => val -> JSM JSObjectRef -- | Given a JavaScript value get its string value (as a Haskell -- Text). May throw JSException. -- --
--   >>> testJSaddle $ show <$> valToText JSNull
--   "null"
--   
--   >>> testJSaddle $ show <$> valToText ()
--   "undefined"
--   
--   >>> testJSaddle $ show <$> valToText True
--   "true"
--   
--   >>> testJSaddle $ show <$> valToText False
--   "false"
--   
--   >>> testJSaddle $ show <$> valToText (1.0 :: Double)
--   "1"
--   
--   >>> testJSaddle $ show <$> valToText (0.0 :: Double)
--   "0"
--   
--   >>> testJSaddle $ show <$> valToText ""
--   ""
--   
--   >>> testJSaddle $ show <$> valToText "1"
--   "1"
--   
valToText :: MakeValueRef val => val -> JSM Text -- | Given a JavaScript value get a JSON string value. May throw -- JSException. -- --
--   >>> testJSaddle $ valToJSON 0 JSNull >>= strToText
--   null
--   
--   >>> testJSaddle $ valToJSON 0 () >>= strToText
--   
-- --
--   >>> testJSaddle $ valToJSON 0 True >>= strToText
--   true
--   
--   >>> testJSaddle $ valToJSON 0 False >>= strToText
--   false
--   
--   >>> testJSaddle $ valToJSON 0 (1.0 :: Double) >>= strToText
--   1
--   
--   >>> testJSaddle $ valToJSON 0 (0.0 :: Double) >>= strToText
--   0
--   
--   >>> testJSaddle $ valToJSON 0 "" >>= strToText
--   ""
--   
--   >>> testJSaddle $ valToJSON 0 "1" >>= strToText
--   "1"
--   
--   >>> testJSaddle $ obj >>= valToJSON 0 >>= strToText
--   {}
--   
valToJSON :: MakeValueRef val => Word -> val -> JSM JSStringRef -- | Convert to a JavaScript value (just an alias for makeValueRef) val :: MakeValueRef value => value -> JSM JSValueRef -- | Make a null JavaScript value valMakeNull :: JSM JSValueRef -- | Make an undefined JavaScript value valMakeUndefined :: JSM JSValueRef -- | Make a JavaScript boolean value valMakeBool :: JSBool -> JSM JSValueRef -- | Make a JavaScript number valMakeNumber :: JSNumber -> JSM JSValueRef -- | Make a JavaScript string valMakeString :: Text -> JSM JSValueRef -- | Derefernce a value reference. -- --
--   >>> testJSaddle $ show <$> deRefVal JSNull
--   ValNull
--   
--   >>> testJSaddle $ show <$> deRefVal ()
--   ValUndefined
--   
--   >>> testJSaddle $ show <$> deRefVal True
--   ValBool True
--   
--   >>> testJSaddle $ show <$> deRefVal False
--   ValBool False
--   
--   >>> testJSaddle $ show <$> deRefVal (1.0 :: Double)
--   ValNumber 1.0
--   
--   >>> testJSaddle $ show <$> deRefVal (0.0 :: Double)
--   ValNumber 0.0
--   
--   >>> testJSaddle $ show <$> deRefVal ""
--   ValString ""
--   
--   >>> testJSaddle $ show <$> deRefVal "1"
--   ValString "1"
--   
--   >>> testJSaddle $ show <$> valToObject True >>= deRefVal
--   ValObject 0x...
--   
deRefVal :: MakeValueRef val => val -> JSM JSValue -- | Make a JavaScript value out of a JSValue ADT. -- --
--   >>> testJSaddle $ valMakeRef ValNull
--   "null"
--   
--   >>> testJSaddle $ valMakeRef ValUndefined
--   "undefined"
--   
--   >>> testJSaddle $ valMakeRef (ValBool True)
--   "true"
--   
--   >>> testJSaddle $ valMakeRef (ValNumber 1)
--   "1"
--   
--   >>> testJSaddle $ valMakeRef (ValString $ pack "Hello")
--   "Hello"
--   
valMakeRef :: JSValue -> JSM JSValueRef instance GHC.Classes.Eq Language.Javascript.JSaddle.Value.JSValue instance GHC.Show.Show Language.Javascript.JSaddle.Value.JSValue instance Language.Javascript.JSaddle.Classes.MakeValueRef Graphics.UI.Gtk.WebKit.JavaScriptCore.JSBase.JSValueRef instance Language.Javascript.JSaddle.Classes.MakeArgRefs Graphics.UI.Gtk.WebKit.JavaScriptCore.JSBase.JSValueRef instance Language.Javascript.JSaddle.Classes.MakeValueRef v => Language.Javascript.JSaddle.Classes.MakeValueRef (Language.Javascript.JSaddle.Monad.JSM v) instance Language.Javascript.JSaddle.Classes.MakeValueRef Language.Javascript.JSaddle.Value.JSNull instance Language.Javascript.JSaddle.Classes.MakeArgRefs Language.Javascript.JSaddle.Value.JSNull instance Language.Javascript.JSaddle.Classes.MakeValueRef Language.Javascript.JSaddle.Value.JSUndefined instance Language.Javascript.JSaddle.Classes.MakeArgRefs () instance Language.Javascript.JSaddle.Classes.MakeValueRef GHC.Types.Bool instance Language.Javascript.JSaddle.Classes.MakeArgRefs GHC.Types.Bool instance Language.Javascript.JSaddle.Classes.MakeValueRef GHC.Types.Double instance Language.Javascript.JSaddle.Classes.MakeArgRefs GHC.Types.Double instance Language.Javascript.JSaddle.Classes.MakeValueRef Data.Text.Internal.Text instance Language.Javascript.JSaddle.Classes.MakeArgRefs Data.Text.Internal.Text instance Language.Javascript.JSaddle.Classes.MakeValueRef GHC.Base.String instance Language.Javascript.JSaddle.Classes.MakeValueRef Language.Javascript.JSaddle.Value.JSValue instance Language.Javascript.JSaddle.Classes.MakeArgRefs Language.Javascript.JSaddle.Value.JSValue instance Language.Javascript.JSaddle.Classes.MakeObjectRef Language.Javascript.JSaddle.Value.JSNull -- | Low level JavaScript object property access. In most cases you should -- use Language.Javascript.JSaddle.Object instead. -- -- This module is mostly here to implement functions needed to use -- JSPropRef. module Language.Javascript.JSaddle.Properties -- | A reference to a property. Implemented as a reference to an object and -- something to find the property. data JSPropRef -- | Object and property name. JSPropRef :: JSObjectRef -> JSStringRef -> JSPropRef -- | Object and property index. JSPropIndexRef :: JSObjectRef -> Index -> JSPropRef -- | Anything that can be used to make a JavaScript property reference class MakePropRef this makePropRef :: MakePropRef this => this -> JSM JSPropRef -- | Get a property value given the object and the name of the property. objGetPropertyByName :: MakeStringRef name => JSObjectRef -> name -> JSValueRefRef -> JSM JSValueRef -- | Get a property value given the object and the index of the property. objGetPropertyAtIndex :: JSObjectRef -> Index -> JSValueRefRef -> JSM JSValueRef -- | Gets the value of a property given a JSPropRef. objGetProperty :: JSPropRef -> JSM JSValueRef -- | This version of objGetProperty is handy when you also need to -- perform. another operation on the object the property is on. objGetProperty' :: JSPropRef -> JSM (JSObjectRef, JSValueRef) -- | Set a property value given the object and the name of the property. objSetPropertyByName :: (MakeStringRef name, MakeValueRef val) => JSObjectRef -> name -> val -> JSPropertyAttributes -> JSValueRefRef -> JSM () -- | Set a property value given the object and the index of the property. objSetPropertyAtIndex :: (MakeValueRef val) => JSObjectRef -> Index -> val -> JSValueRefRef -> JSM () -- | Sets the value of a property given a JSPropRef. objSetProperty :: (MakeValueRef val) => JSPropRef -> val -> JSM () instance Language.Javascript.JSaddle.Classes.MakePropRef Language.Javascript.JSaddle.PropRef.JSPropRef instance Language.Javascript.JSaddle.Classes.MakePropRef prop => Language.Javascript.JSaddle.Classes.MakePropRef (Language.Javascript.JSaddle.Monad.JSM prop) instance Language.Javascript.JSaddle.Classes.MakeObjectRef Language.Javascript.JSaddle.PropRef.JSPropRef instance Language.Javascript.JSaddle.Classes.MakeValueRef Language.Javascript.JSaddle.PropRef.JSPropRef instance Language.Javascript.JSaddle.Classes.MakeArgRefs Language.Javascript.JSaddle.PropRef.JSPropRef -- | Interface to JavaScript object module Language.Javascript.JSaddle.Object type JSObjectRef = Ptr OpaqueJSValue -- | Anything that can be used to make a JavaScript object reference class MakeObjectRef this makeObjectRef :: MakeObjectRef this => this -> JSM JSObjectRef -- | Lookup a property based on its name. This function just constructs a -- JSPropRef the lookup is delayed until we use the JSPropRef. This makes -- it a bit lazy compared to JavaScript's . operator. -- --
--   >>> testJSaddle $ eval "'Hello World'.length"
--   
--   >>> testJSaddle $ val "Hello World" ! "length"
--   11
--   
(!) :: (MakeObjectRef this, MakeStringRef name) => this -> name -> JSM JSPropRef -- | Lookup a property based on its index. This function just constructs a -- JSPropRef the lookup is delayed until we use the JSPropRef. This makes -- it a bit lazy compared to JavaScript's [] operator. -- --
--   >>> testJSaddle $ eval "'Hello World'[6]"
--   
--   >>> testJSaddle $ val "Hello World" !! 6
--   W
--   
(!!) :: (MakeObjectRef this) => this -> Index -> JSM JSPropRef -- | Makes a getter for a particular property name. -- --
--   js name = to (!name)
--   
-- --
--   >>> testJSaddle $ eval "'Hello World'.length"
--   
--   >>> testJSaddle $ val "Hello World" ^. js "length"
--   11
--   
js :: (MakeObjectRef s, MakeStringRef name) => name -> IndexPreservingGetter s (JSM JSPropRef) -- | Java script function applications have this type type JSF = MakeObjectRef o => IndexPreservingGetter o (JSM JSValueRef) -- | Handy way to call a function -- --
--   jsf name = js name . to (# args)
--   
-- --
--   >>> testJSaddle $ val "Hello World" ^. jsf "indexOf" ["World"]
--   6
--   
jsf :: (MakeStringRef name, MakeArgRefs args) => name -> args -> JSF -- | Handy way to call a function that expects no arguments -- --
--   js0 name = jsf name ()
--   
-- --
--   >>> testJSaddle $ val "Hello World" ^. js0 "toLowerCase"
--   hello world
--   
js0 :: (MakeStringRef name) => name -> JSF -- | Handy way to call a function that expects one argument -- --
--   js1 name a0 = jsf name [a0]
--   
-- --
--   >>> testJSaddle $ val "Hello World" ^. js1 "indexOf" "World"
--   6
--   
js1 :: (MakeStringRef name, MakeValueRef a0) => name -> a0 -> JSF -- | Handy way to call a function that expects two arguments js2 :: (MakeStringRef name, MakeValueRef a0, MakeValueRef a1) => name -> a0 -> a1 -> JSF -- | Handy way to call a function that expects three arguments js3 :: (MakeStringRef name, MakeValueRef a0, MakeValueRef a1, MakeValueRef a2) => name -> a0 -> a1 -> a2 -> JSF -- | Handy way to call a function that expects four arguments js4 :: (MakeStringRef name, MakeValueRef a0, MakeValueRef a1, MakeValueRef a2, MakeValueRef a3) => name -> a0 -> a1 -> a2 -> a3 -> JSF -- | Handy way to call a function that expects five arguments js5 :: (MakeStringRef name, MakeValueRef a0, MakeValueRef a1, MakeValueRef a2, MakeValueRef a3, MakeValueRef a4) => name -> a0 -> a1 -> a2 -> a3 -> a4 -> JSF -- | Handy way to get and hold onto a reference top level javascript -- --
--   >>> testJSaddle $ eval "w = console; w.log('Hello World')"
--   
--   >>> testJSaddle $ do w <- jsg "console"; w ^. js "log" # ["Hello World"]
--   11
--   
jsg :: MakeStringRef a => a -> JSM JSPropRef -- | Call a JavaScript function -- --
--   >>> testJSaddle $ eval "var j = {}; j.x = 1; j.x"
--   
--   >>> testJSaddle $ do {j <- eval "({})"; j!"x" <# 1; j!"x"}
--   1
--   
(<#) :: (MakePropRef prop, MakeValueRef val) => prop -> val -> JSM JSPropRef -- | Call a JavaScript function -- --
--   >>> testJSaddle $ eval "'Hello World'.indexOf('World')"
--   
--   >>> testJSaddle $ val "Hello World" ! "indexOf" # ["World"]
--   6
--   
(#) :: (MakePropRef prop, MakeArgRefs args) => prop -> args -> JSM JSValueRef -- | Use this to create a new JavaScript object -- -- If you pass more than 7 arguments to a constructor for a built in -- JavaScript type (like Date) then this function will fail. -- --
--   >>> testJSaddle $ new "Date" (2013, 1, 1)
--   Fri Feb 01 2013 00:00:00 GMT+1300 (NZDT)
--   
new :: (MakeObjectRef constructor, MakeArgRefs args) => constructor -> args -> JSM JSValueRef -- | Call function with a given this. In most cases you should use -- '#'. -- --
--   >>> testJSaddle $ eval "(function(){return this;}).apply('Hello', [])"
--   
--   >>> testJSaddle $ do { test <- eval "(function(){return this;})"; call test (val "Hello") () }
--   Hello
--   
call :: (MakeObjectRef function, MakeObjectRef this, MakeArgRefs args) => function -> this -> args -> JSM JSValueRef -- | Make an empty object using the default constuctor -- --
--   >>> testJSaddle $ eval "var a = {}; a.x = 'Hello'; a.x"
--   
--   >>> testJSaddle $ do { a <- obj; a ^. js "x" <# "Hello"; a ^. js "x" }
--   Hello
--   
obj :: JSM JSObjectRef function :: MakeStringRef name => name -> JSCallAsFunction -> JSM JSObjectRef -- | Short hand ::JSCallAsFunction so a haskell function can be -- passed to a to a JavaScipt one. -- --
--   >>> testJSaddle $ eval "(function(f) {f('Hello');})(function (a) {console.log(a)})"
--   
--   >>> testJSaddle $ call (eval "(function(f) {f('Hello');})") global [fun $ \ _ _ args -> valToText (head args) >>= (liftIO . putStrLn . T.unpack) ]
--   Hello
--   undefined
--   
fun :: JSCallAsFunction -> JSCallAsFunction -- | Type used for Haskell functions called from JavaScript. type JSCallAsFunction = JSValueRef Function object -> JSValueRef this -> [JSValueRef] Function arguments -> JSM JSUndefined Only '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. -- | Make an JavaScript array from a list of values -- --
--   >>> testJSaddle $ eval "['Hello', 'World'][1]"
--   
--   >>> testJSaddle $ array ["Hello", "World"] !! 1
--   World
--   
--   >>> testJSaddle $ eval "['Hello', null, undefined, true, 1]"
--   
--   >>> testJSaddle $ array ("Hello", JSNull, (), True, 1.0::Double)
--   Hello,,,true,1
--   
array :: MakeArgRefs args => args -> JSM JSObjectRef -- | JavaScript's global object global :: JSM JSObjectRef -- | Get a list containing the property names present on a given object propertyNames :: MakeObjectRef this => this -> JSM [JSStringRef] -- | Call a JavaScript object as function. Consider using '#'. objCallAsFunction :: MakeArgRefs args => JSObjectRef -> JSObjectRef -> args -> JSValueRefRef -> JSM JSValueRef -- | Call a JavaScript object as a constructor. Consider using new. -- -- If you pass more than 7 arguments to a constructor for a built in -- JavaScript type (like Date) then this function will fail. objCallAsConstructor :: MakeArgRefs args => JSObjectRef -> args -> JSValueRefRef -> JSM JSValueRef instance Language.Javascript.JSaddle.Classes.MakeObjectRef Graphics.UI.Gtk.WebKit.JavaScriptCore.JSBase.JSObjectRef instance Language.Javascript.JSaddle.Classes.MakeObjectRef v => Language.Javascript.JSaddle.Classes.MakeObjectRef (Language.Javascript.JSaddle.Monad.JSM v) instance Language.Javascript.JSaddle.Classes.MakeValueRef Language.Javascript.JSaddle.Object.JSCallAsFunction instance Language.Javascript.JSaddle.Classes.MakeArgRefs Language.Javascript.JSaddle.Object.JSCallAsFunction -- | If you just want to run some JavaScript that you have as a string this -- is you can use eval or evaluateScript. module Language.Javascript.JSaddle.Evaluate -- | Evaluates a script (like eval in java script). Unlike eval this -- function lets you specify a source URL and starting line number for -- beter error information. -- --
--   >>> testJSaddle $ (evaluateScript "\n\n{" global "FileName" 53 >>= valToText) `catch` \(JSException e) -> array (e,e!"sourceURL", e!"line") >>= valToText
--   SyntaxError: Expected token '}',FileName,55
--   
evaluateScript :: (MakeStringRef script, MakeObjectRef this, MakeStringRef url) => script -> this -> url -> Int -> JSM JSValueRef -- | Evaluates a script (like eval in java script) -- --
--   >>> testJSaddle $ eval "1+1"
--   2
--   
eval :: MakeStringRef script => script -> JSM JSValueRef -- | This package provides an EDSL for calling JavaScript code using the -- JavaScriptCore engine and low level Haskell bindings in the -- webkit-javascriptcore library -- https://github.com/ghcjs/webkit-javascriptcore. module Language.Javascript.JSaddle