packages feed

jsaddle 0.4.0.1 → 0.4.0.2

raw patch · 12 files changed

+8/−133 lines, 12 files

Files

jsaddle.cabal view
@@ -1,5 +1,5 @@ name: jsaddle-version: 0.4.0.1+version: 0.4.0.2 cabal-version: >=1.10 build-type: Simple license: MIT
src/Language/Javascript/JSaddle/Arguments.hs view
@@ -28,18 +28,15 @@  instance MakeArgs arg => MakeArgs (JSM arg) where     makeArgs arg = arg >>= makeArgs-    {-# INLINE makeArgs #-}  instance ToJSVal arg => MakeArgs [arg] where     makeArgs = mapM toJSVal-    {-# INLINE makeArgs #-}  instance (ToJSVal arg1, ToJSVal arg2) => MakeArgs (arg1, arg2) where     makeArgs (arg1, arg2) = do         rarg1 <- toJSVal arg1         rarg2 <- toJSVal arg2         return [rarg1, rarg2]-    {-# INLINE makeArgs #-}  instance (ToJSVal arg1, ToJSVal arg2, ToJSVal arg3) => MakeArgs (arg1, arg2, arg3) where     makeArgs (arg1, arg2, arg3) = do@@ -47,7 +44,6 @@         rarg2 <- toJSVal arg2         rarg3 <- toJSVal arg3         return [rarg1, rarg2, rarg3]-    {-# INLINE makeArgs #-}  instance (ToJSVal arg1, ToJSVal arg2, ToJSVal arg3, ToJSVal arg4) => MakeArgs (arg1, arg2, arg3, arg4) where     makeArgs (arg1, arg2, arg3, arg4) = do@@ -56,7 +52,6 @@         rarg3 <- toJSVal arg3         rarg4 <- toJSVal arg4         return [rarg1, rarg2, rarg3, rarg4]-    {-# INLINE makeArgs #-}  instance (ToJSVal arg1, ToJSVal arg2, ToJSVal arg3, ToJSVal arg4, ToJSVal arg5) => MakeArgs (arg1, arg2, arg3, arg4, arg5) where     makeArgs (arg1, arg2, arg3, arg4, arg5) = do@@ -66,7 +61,6 @@         rarg4 <- toJSVal arg4         rarg5 <- toJSVal arg5         return [rarg1, rarg2, rarg3, rarg4, rarg5]-    {-# INLINE makeArgs #-}   instance (ToJSVal arg1, ToJSVal arg2, ToJSVal arg3, ToJSVal arg4, ToJSVal arg5, ToJSVal arg6) => MakeArgs (arg1, arg2, arg3, arg4, arg5, arg6) where@@ -78,5 +72,4 @@         rarg5 <- toJSVal arg5         rarg6 <- toJSVal arg6         return [rarg1, rarg2, rarg3, rarg4, rarg5, rarg6]-    {-# INLINE makeArgs #-} 
src/Language/Javascript/JSaddle/Classes.hs view
@@ -38,10 +38,8 @@  instance ToJSVal Object where     toJSVal (Object r) = return r-    {-# INLINE toJSVal #-}  -- | If we already have a Object we are fine instance MakeObject Object where     makeObject = return-    {-# INLINE makeObject #-} 
src/Language/Javascript/JSaddle/Evaluate.hs view
@@ -63,7 +63,6 @@                -> JSM JSVal #ifdef ghcjs_HOST_OS evaluateScript script this url line = liftIO $ js_eval (toJSString script)-{-# INLINE evaluateScript #-} foreign import javascript unsafe "$r = eval($1);"     js_eval :: JSString -> IO JSVal #else@@ -76,7 +75,6 @@                 withJSString (toJSString url) $ \url' ->                     rethrow $ liftIO . jsevaluatescript gctxt script' this' url' line     makeNewJSVal result-{-# INLINE evaluateScript #-} #endif  -- | Evaluates a script (like eval in java script)@@ -87,4 +85,3 @@      => script         -- ^ JavaScript to evaluate      -> JSM JSVal eval script = evaluateScript script nullObject nullJSString 1-{-# INLINE eval #-}
src/Language/Javascript/JSaddle/Monad.hs view
@@ -42,10 +42,8 @@ import Language.Javascript.JSaddle.Native (makeNewJSVal) import Foreign (nullPtr, alloca) import Foreign.Storable (Storable(..))-import GI.WebKit.Types-       (WebView(..)) import GI.WebKit.Objects.WebView-       (webViewGetMainFrame)+       (WebView(..), webViewGetMainFrame) import GI.WebKit.Objects.WebFrame        (webFrameGetGlobalContext) import GI.GLib (idleAdd)@@ -87,7 +85,6 @@ t `catch` c = do     r <- ask     liftIO (runReaderT t r `E.catch` \e -> runReaderT (c e) r)-{-# INLINE catch #-}  -- | Wrapped version of 'E.bracket' that runs in a MonadIO that works --   a bit better with 'JSM'@@ -98,7 +95,6 @@         (runReaderT aquire r)         (\x -> runReaderT (release x) r)         (\x -> runReaderT (f x) r)-{-# INLINE bracket #-}  -- | Handle JavaScriptCore functions that take a MutableJSArray in order --   to throw exceptions.@@ -132,7 +128,6 @@     withForeignPtr gctxt $ \ptr ->         runReaderT f (castPtr ptr) #endif-{-# INLINE runJSaddle #-}  postGUIAsyncJS :: JSM () -> JSM () #ifdef ghcjs_HOST_OS@@ -142,7 +137,6 @@     r <- ask     liftIO . postGUIAsync $ runReaderT f r #endif-{-# INLINE postGUIAsyncJS #-}  postGUISyncJS :: JSM a -> JSM a #ifdef ghcjs_HOST_OS@@ -152,5 +146,4 @@     r <- ask     liftIO . postGUISync $ runReaderT f r #endif-{-# INLINE postGUISyncJS #-} 
src/Language/Javascript/JSaddle/Native.hs view
@@ -97,6 +97,5 @@ withToJSVal val f = do     v <- toJSVal val     withJSVal v f-{-# INLINE withToJSVal #-} #endif 
src/Language/Javascript/JSaddle/Object.hs view
@@ -155,7 +155,6 @@ --   as it returns something we can make into a Object. instance MakeObject v => MakeObject (JSM v) where     makeObject v = v >>= makeObject-    {-# INLINE makeObject #-}  -- | Lookup a property based on its name. --@@ -172,7 +171,6 @@     rethrow $ objGetPropertyByName rthis rname   where     rname = toJSString name-{-# INLINE (!) #-}  -- | Lookup a property based on its index. --@@ -187,7 +185,6 @@ this !! index = do     rthis <- makeObject this     rethrow $ objGetPropertyAtIndex rthis index-{-# INLINE (!!) #-}  -- | Makes a getter for a particular property name. --@@ -201,7 +198,6 @@    => name          -- ^ Name of the property to find    -> IndexPreservingGetter s (JSM JSVal) js name = to (!name)-{-# INLINE js #-}  -- | Makes a setter for a particular property name. --@@ -216,7 +212,6 @@    -> val    -> forall o . MakeObject o => IndexPreservingGetter o (JSM ()) jss name val = to (\o -> o <# name $ val)-{-# INLINE jss #-}  -- | Handy way to call a function --@@ -226,7 +221,6 @@ -- 6 jsf :: (ToJSString name, MakeArgs args) => name -> args -> JSF jsf name args = to (\o -> o # name $ args)-{-# INLINE jsf #-}  -- | Java script function applications have this type type JSF = forall o . MakeObject o => IndexPreservingGetter o (JSM JSVal)@@ -239,7 +233,6 @@ -- hello world js0 :: (ToJSString name) => name -> JSF js0 name = jsf name ()-{-# INLINE js0 #-}  -- | Handy way to call a function that expects one argument --@@ -249,32 +242,27 @@ -- 6 js1 :: (ToJSString name, ToJSVal a0) => name -> a0 -> JSF js1 name a0 = jsf name [a0]-{-# INLINE js1 #-}  -- | Handy way to call a function that expects two arguments js2 :: (ToJSString name, ToJSVal a0, ToJSVal a1) => name -> a0 -> a1 -> JSF js2 name a0 a1 = jsf name (a0, a1)-{-# INLINE js2 #-}  -- | Handy way to call a function that expects three arguments js3 :: (ToJSString name, ToJSVal a0, ToJSVal a1, ToJSVal a2)     => name -> a0 -> a1 -> a2 -> JSF js3 name a0 a1 a2 = jsf name (a0, a1, a2)-{-# INLINE js3 #-}  -- | Handy way to call a function that expects four arguments js4 :: (ToJSString name, ToJSVal a0, ToJSVal a1, ToJSVal a2,         ToJSVal a3)     => name -> a0 -> a1 -> a2 -> a3 -> JSF js4 name a0 a1 a2 a3 = jsf name (a0, a1, a2, a3)-{-# INLINE js4 #-}  -- | Handy way to call a function that expects five arguments js5 :: (ToJSString name, ToJSVal a0, ToJSVal a1, ToJSVal a2,         ToJSVal a3, ToJSVal a4)     => name -> a0 -> a1 -> a2 -> a3 -> a4 -> JSF js5 name a0 a1 a2 a3 a4 = jsf name (a0, a1, a2, a3, a4)-{-# INLINE js5 #-}   -- | Handy way to get and hold onto a reference top level javascript@@ -289,7 +277,6 @@ -- undefined jsg :: ToJSString a => a -> JSM JSVal jsg name = global ! name-{-# INLINE jsg #-}  -- | Handy way to call a function --@@ -301,7 +288,6 @@ -- 5 jsgf :: (ToJSString name, MakeArgs args) => name -> args -> JSM JSVal jsgf name = global # name-{-# INLINE jsgf #-}  -- | Handy way to call a function that expects no arguments --@@ -311,7 +297,6 @@ -- TypeError:...undefined...is not an objec... jsg0 :: (ToJSString name) => name -> JSM JSVal jsg0 name = jsgf name ()-{-# INLINE jsg0 #-}  -- | Handy way to call a function that expects one argument --@@ -321,32 +306,27 @@ -- 5 jsg1 :: (ToJSString name, ToJSVal a0) => name -> a0 -> JSM JSVal jsg1 name a0 = jsgf name [a0]-{-# INLINE jsg1 #-}  -- | Handy way to call a function that expects two arguments jsg2 :: (ToJSString name, ToJSVal a0, ToJSVal a1) => name -> a0 -> a1 -> JSM JSVal jsg2 name a0 a1 = jsgf name (a0, a1)-{-# INLINE jsg2 #-}  -- | Handy way to call a function that expects three arguments jsg3 :: (ToJSString name, ToJSVal a0, ToJSVal a1, ToJSVal a2)     => name -> a0 -> a1 -> a2 -> JSM JSVal jsg3 name a0 a1 a2 = jsgf name (a0, a1, a2)-{-# INLINE jsg3 #-}  -- | Handy way to call a function that expects four arguments jsg4 :: (ToJSString name, ToJSVal a0, ToJSVal a1, ToJSVal a2,         ToJSVal a3)     => name -> a0 -> a1 -> a2 -> a3 -> JSM JSVal jsg4 name a0 a1 a2 a3 = jsgf name (a0, a1, a2, a3)-{-# INLINE jsg4 #-}  -- | Handy way to call a function that expects five arguments jsg5 :: (ToJSString name, ToJSVal a0, ToJSVal a1, ToJSVal a2,         ToJSVal a3, ToJSVal a4)     => name -> a0 -> a1 -> a2 -> a3 -> a4 -> JSM JSVal jsg5 name a0 a1 a2 a3 a4 = jsgf name (a0, a1, a2, a3, a4)-{-# INLINE jsg5 #-}  -- | Call a JavaScript function --@@ -362,7 +342,6 @@     f <- rethrow $ objGetPropertyByName rthis name     f' <- valToObject f     rethrow $ objCallAsFunction f' rthis args-{-# INLINE (#) #-}  -- | Call a JavaScript function --@@ -378,7 +357,6 @@     f <- rethrow $ objGetPropertyAtIndex rthis index     f' <- valToObject f     rethrow $ objCallAsFunction f' rthis args-{-# INLINE (##) #-}  -- | Set a JavaScript property --@@ -395,7 +373,6 @@ (<#) this name val = do     rthis <- makeObject this     rethrow $ objSetPropertyByName rthis name val 0-{-# INLINE (<#) #-}  -- | Set a JavaScript property --@@ -412,7 +389,6 @@ (<##) this index val = do     rthis <- makeObject this     rethrow $ objSetPropertyAtIndex rthis index val-{-# INLINE (<##) #-}  -- | Use this to create a new JavaScript object --@@ -428,7 +404,6 @@ new constructor args = do     f <- makeObject constructor     rethrow $ objCallAsConstructor f args-{-# INLINE new #-}  -- | Call function with a given @this@.  In most cases you should use '#'. --@@ -442,7 +417,6 @@     rfunction <- makeObject f     rthis     <- makeObject this     rethrow $ objCallAsFunction rfunction rthis args-{-# INLINE call #-}  -- | Make an empty object using the default constuctor --@@ -458,7 +432,6 @@     gctxt <- ask     Object <$> (liftIO (jsobjectmake gctxt nullPtr nullPtr) >>= makeNewJSVal) #endif-{-# INLINE obj #-}  -- | Type used for Haskell functions called from JavaScript. type JSCallAsFunction = JSVal      -- ^ Function object@@ -482,7 +455,6 @@ -- undefined fun :: JSCallAsFunction -> JSCallAsFunction fun = id-{-# INLINE fun #-}  #ifdef ghcjs_HOST_OS type HaskellCallback = Callback (JSVal -> JSVal -> IO ())@@ -538,20 +510,17 @@  instance ToJSVal Function where     toJSVal (Function _ f) = toJSVal f-    {-# INLINE toJSVal #-}  -- | 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 ToJSVal JSCallAsFunction where     toJSVal f = functionObject <$> function nullJSString f >>= toJSVal-    {-# INLINE toJSVal #-}  instance MakeArgs JSCallAsFunction where     makeArgs f = do         rarg <- functionObject <$> function nullJSString f >>= toJSVal         return [rarg]-    {-# INLINE makeArgs #-}  makeArray :: MakeArgs args => args -> MutableJSArray -> JSM Object #ifdef ghcjs_HOST_OS@@ -568,7 +537,6 @@                 jsobjectmakearray gctxt (fromIntegral len) ptr exceptions     Object <$> makeNewJSVal result #endif-{-# INLINE makeArray #-}  -- | Make an JavaScript array from a list of values --@@ -586,45 +554,35 @@ -- Make an array out of various lists instance ToJSVal [JSVal] where     toJSVal = toJSVal . array-    {-# INLINE toJSVal #-}  instance ToJSVal [JSM JSVal] where     toJSVal = toJSVal . array-    {-# INLINE toJSVal #-}  instance ToJSVal [Double] where     toJSVal = toJSVal . array-    {-# INLINE toJSVal #-}  instance ToJSVal [Float] where     toJSVal = toJSVal . array-    {-# INLINE toJSVal #-}  instance ToJSVal [Int] where     toJSVal = toJSVal . array-    {-# INLINE toJSVal #-}  instance ToJSVal [JSString] where     toJSVal = toJSVal . array-    {-# INLINE toJSVal #-}  instance ToJSVal [String] where     toJSVal = toJSVal . array-    {-# INLINE toJSVal #-}  instance ToJSVal [Text] where     toJSVal = toJSVal . array-    {-# INLINE toJSVal #-}  instance ToJSVal [Bool] where     toJSVal = toJSVal . array-    {-# INLINE toJSVal #-}  -- | JavaScript's global object global :: JSM Object #ifdef ghcjs_HOST_OS global = liftIO js_window-{-# INLINE global #-} foreign import javascript unsafe "$r = window"     js_window :: IO Object #else@@ -632,7 +590,6 @@     gctxt <- ask     result <- liftIO $ jscontextgetglobalobject gctxt     Object <$> makeNewJSVal result-{-# INLINE global #-} #endif  -- | Get an array containing the property names present on a given object@@ -643,36 +600,30 @@     this' <- makeObject this     withObject this' $ \rthis ->         liftIO $ jsobjectcopypropertynames gctxt rthis-{-# INLINE copyPropertyNames #-}  -- | Get the number of names in a property name array propertyNamesCount :: MonadIO m => JSPropertyNameArray -> m CSize propertyNamesCount names = liftIO $ jspropertynamearraygetcount names-{-# INLINE propertyNamesCount #-}  -- | Get a name out of a property name array propertyNamesAt :: MonadIO m => JSPropertyNameArray -> CSize -> m JSString propertyNamesAt names index = liftIO $ jspropertynamearraygetnameatindex names index >>= makeNewJSString-{-# INLINE propertyNamesAt #-}  -- | Convert property array to a list propertyNamesList :: MonadIO m => JSPropertyNameArray -> m [JSString] propertyNamesList names = do     count <- propertyNamesCount names     mapM (propertyNamesAt names) $ enumFromTo 0 (count - 1)-{-# INLINE propertyNamesList #-} #endif  -- | Get a list containing the property names present on a given object propertyNames :: MakeObject this => this -> JSM [JSString] #ifdef ghcjs_HOST_OS propertyNames this = makeObject this >>= liftIO . js_propertyNames >>= liftIO . (fmap (map pFromJSVal)) . Array.toListIO-{-# INLINE propertyNames #-} foreign import javascript unsafe "$r = []; h$forIn($1, function(n){$r.push(n);})"     js_propertyNames :: Object -> IO JSArray #else propertyNames this = copyPropertyNames this >>= propertyNamesList-{-# INLINE propertyNames #-} #endif  -- | Get a list containing references to all the  properties present on a given object@@ -690,7 +641,6 @@ objCallAsFunction f this args exceptions = do     rargs <- makeArgs args >>= liftIO . Array.fromListIO     liftIO $ js_apply f this rargs exceptions-{-# INLINE objCallAsFunction #-} foreign import javascript unsafe "try { $r = $1.apply($2, $3) } catch(e) { $4[0] = e }"     js_apply :: Object -> Object -> MutableJSArray -> MutableJSArray -> IO JSVal #else@@ -704,7 +654,6 @@                     liftIO $ withArrayLen rargs' $ \ largs pargs ->                         jsobjectcallasfunction gctxt rfunction rthis (fromIntegral largs) pargs exceptions     makeNewJSVal result-{-# INLINE objCallAsFunction #-} #endif  -- | Call a JavaScript object as a constructor. Consider using 'new'.
src/Language/Javascript/JSaddle/Properties.hs view
@@ -58,7 +58,6 @@                      -> JSM JSVal      -- ^ returns the property value. #ifdef ghcjs_HOST_OS objGetPropertyByName this name = liftIO . js_tryGetProp (toJSString name) this-{-# INLINE objGetPropertyByName #-} foreign import javascript unsafe "try { $r=$2[$1] } catch(e) { $3[0] = e }"     js_tryGetProp :: JSString -> Object -> MutableJSArray -> IO JSVal #else@@ -67,7 +66,6 @@     withObject this $ \rthis ->         withJSString (toJSString name) $ \name' ->             (liftIO $ jsobjectgetproperty gctxt rthis name' exceptions) >>= makeNewJSVal-{-# INLINE objGetPropertyByName #-} #endif  -- | Get a property value given the object and the index of the property.@@ -77,7 +75,6 @@                       -> JSM JSVal      -- ^ returns the property value. #ifdef ghcjs_HOST_OS objGetPropertyAtIndex this index = liftIO . js_tryIndex index this-{-# INLINE objGetPropertyAtIndex #-} foreign import javascript unsafe "try { $r=$2[$1] } catch(e) { $3[0] = e }"     js_tryIndex :: Index -> Object -> MutableJSArray -> IO JSVal #else@@ -85,7 +82,6 @@     gctxt <- ask     withObject this $ \rthis ->         (liftIO $ jsobjectgetpropertyatindex gctxt rthis index exceptions) >>= makeNewJSVal-{-# INLINE objGetPropertyAtIndex #-} #endif  -- | Set a property value given the object and the name of the property.@@ -100,7 +96,6 @@ objSetPropertyByName this name val attributes exceptions = do     vref <- toJSVal val     liftIO $ js_trySetProp (toJSString name) this vref exceptions-{-# INLINE objSetPropertyByName #-} foreign import javascript unsafe "try { $2[$1]=$3 } catch(e) { $4[0] = e }"     js_trySetProp :: JSString -> Object -> JSVal -> MutableJSArray -> IO () #else@@ -110,7 +105,6 @@         withJSString (toJSString name) $ \name' ->         withToJSVal val $ \rval ->             liftIO $ jsobjectsetproperty gctxt rthis name' rval attributes exceptions-{-# INLINE objSetPropertyByName #-} #endif  -- | Set a property value given the object and the index of the property.@@ -124,7 +118,6 @@ objSetPropertyAtIndex this index val exceptions = do     vref <- toJSVal val     liftIO $ js_trySetAtIndex index this vref exceptions-{-# INLINE objSetPropertyAtIndex #-} foreign import javascript unsafe "try { $2[$1]=$3 } catch(e) { $4[0] = e }"     js_trySetAtIndex :: Index -> Object -> JSVal -> MutableJSArray -> IO () #else@@ -133,6 +126,5 @@     withObject this $ \rthis ->         withToJSVal val $ \rval ->             liftIO $ jsobjectsetpropertyatindex gctxt rthis index rval exceptions-{-# INLINE objSetPropertyAtIndex #-} #endif 
src/Language/Javascript/JSaddle/String.hs view
@@ -54,7 +54,6 @@     p <- jsstringgetcharactersptr jsstring     T.fromPtr (castPtr p) (fromIntegral l) #endif-{-# INLINE strToText #-}  -- | Convert a Haskell 'Text' to a JavaScript string textToStr :: Text -> JSString@@ -65,7 +64,6 @@     useAsPtr text $ \p l ->         jsstringcreatewithcharacters (castPtr p) (fromIntegral l) >>= makeNewJSString #endif-{-# INLINE textToStr #-}  nullJSString :: JSString #ifdef ghcjs_HOST_OS
src/Language/Javascript/JSaddle/Test.hs view
@@ -108,7 +108,7 @@             debugLog "fork"             _ <- forkIO $ do                 debugLog "initGUI"-                _ <- Gtk.init Nothing+                _ <- Gtk.init mempty                 debugLog "windowNew"                 window <- windowNew WindowTypeToplevel                 debugLog "timeoutAdd"
src/Language/Javascript/JSaddle/Value.hs view
@@ -170,7 +170,6 @@     withToJSVal value $ \rval ->         liftIO $ jsvaluetoboolean gctxt rval #endif-{-# INLINE valToBool #-}  -- | Given a JavaScript value get its numeric value. --   May throw JSException.@@ -194,14 +193,12 @@ valToNumber :: ToJSVal value => value -> JSM Double #ifdef ghcjs_HOST_OS valToNumber value = jsrefToNumber <$> toJSVal value-{-# INLINE valToNumber #-} foreign import javascript unsafe "$r = Number($1);" jsrefToNumber :: JSVal -> Double #else valToNumber value = do     gctxt <- ask     withToJSVal value $ \rval ->         rethrow $ liftIO . jsvaluetonumber gctxt rval-{-# INLINE valToNumber #-} #endif  -- | Given a JavaScript value get its string value (as a JavaScript string).@@ -226,14 +223,12 @@ valToStr :: ToJSVal value => value -> JSM JSString #ifdef ghcjs_HOST_OS valToStr value = jsrefToString <$> toJSVal value-{-# INLINE valToStr #-} foreign import javascript unsafe "$r = $1.toString();" jsrefToString :: JSVal -> JSString #else valToStr value = do     gctxt <- ask     withToJSVal value $ \rval ->         rethrow (liftIO . jsvaluetostringcopy gctxt rval) >>= wrapJSString-{-# INLINE valToStr #-} #endif  -- | Given a JavaScript value get its string value (as a Haskell 'Text').@@ -257,7 +252,6 @@ -- "1" valToText :: ToJSVal value => value -> JSM Text valToText jsvar = valToStr jsvar >>= strToText-{-# INLINE valToText #-}  -- | Given a JavaScript value get a JSON string value. --   May throw JSException.@@ -283,14 +277,12 @@ valToJSON :: ToJSVal value => Word -> value -> JSM JSString #ifdef ghcjs_HOST_OS valToJSON indent value = jsrefToJSON <$> toJSVal value-{-# INLINE valToJSON #-} foreign import javascript unsafe "$r = JSON.stringify($1);" jsrefToJSON :: JSVal -> JSString #else valToJSON indent value = do     gctxt <- ask     withToJSVal value $ \rval ->         rethrow (liftIO . jsvaluecreatejsonstring gctxt rval (fromIntegral indent)) >>= wrapJSString-{-# INLINE valToJSON #-} #endif  -- | Given a JavaScript value get its object value.@@ -321,34 +313,28 @@     withToJSVal value $ \rval ->         rethrow (liftIO . jsvaluetoobject gctxt rval) >>= makeNewJSVal #endif-{-# INLINE valToObject #-}  instance MakeObject JSVal where     makeObject = valToObject-    {-# INLINE makeObject #-}  -- | Convert to a JavaScript value (just an alias for 'toJSVal') val :: ToJSVal value     => value          -- ^ value to convert to a JavaScript value     -> JSM JSVal val = toJSVal-{-# INLINE val #-}  -- | If we already have a JSVal we are fine instance ToJSVal JSVal where     toJSVal = return-    {-# INLINE toJSVal #-}  -- | A single JSVal can be used as the argument list instance MakeArgs JSVal where     makeArgs arg = return [arg]-    {-# INLINE makeArgs #-}  -- | JSVal can be made by evaluating a function in 'JSM' as long --   as it returns something we can make into a JSVal. instance ToJSVal v => ToJSVal (JSM v) where     toJSVal v = v >>= toJSVal-    {-# INLINE toJSVal #-}  ----------- null --------------- -- | Make a @null@ JavaScript value@@ -358,23 +344,19 @@ #else valMakeNull = ask >>= (liftIO . jsvaluemakenull) >>= makeNewJSVal #endif-{-# INLINE valMakeNull #-}  -- | Makes a @null@ JavaScript value instance ToJSVal JSNull where     toJSVal = const valMakeNull-    {-# INLINE toJSVal #-}  -- | Makes an argument list with just a single @null@ JavaScript value instance MakeArgs JSNull where     makeArgs _ = valMakeNull >>= (\ref -> return [ref])-    {-# INLINE makeArgs #-}  -- | Makes a JSVal or @null@ JavaScript value instance ToJSVal a => ToJSVal (Maybe a) where     toJSVal Nothing = valMakeNull     toJSVal (Just a) = toJSVal a-    {-# INLINE toJSVal #-}  -- | Test a JavaScript value to see if it is @null@ valIsNull :: ToJSVal value => value -> JSM Bool@@ -386,7 +368,6 @@     withToJSVal value $ \rval ->         liftIO $ jsvalueisnull gctxt rval #endif-{-# INLINE valIsNull #-}  ----------- undefined --------------- -- | Make an @undefined@ JavaScript value@@ -396,12 +377,10 @@ #else valMakeUndefined = ask >>= (liftIO . jsvaluemakeundefined) >>= makeNewJSVal #endif-{-# INLINE valMakeUndefined #-}  -- | Makes an @undefined@ JavaScript value instance ToJSVal JSUndefined where     toJSVal = const valMakeUndefined-    {-# INLINE toJSVal #-}  --We can't allow this if JSUndefined is () as () is no args not "(null)". --Use [()] instead.@@ -411,7 +390,6 @@ -- | This allows us to pass no arguments easily (altenative would be to use @[]::[JSVal]@). instance MakeArgs () where     makeArgs _ = return []-    {-# INLINE makeArgs #-}  -- | Test a JavaScript value to see if it is @undefined@ valIsUndefined :: ToJSVal value => value -> JSM Bool@@ -423,7 +401,6 @@     withToJSVal value $ \rval ->         liftIO $ jsvalueisundefined gctxt rval #endif-{-# INLINE valIsUndefined #-}  -- | Convert a JSVal to a Maybe JSVal (converting null and undefined to Nothing) maybeNullOrUndefined :: ToJSVal value => value -> JSM (Maybe JSVal)@@ -435,7 +412,6 @@             valIsUndefined rval >>= \case                 True -> return Nothing                 _    -> return (Just rval)-{-# INLINE maybeNullOrUndefined #-}  maybeNullOrUndefined' :: ToJSVal value => (JSVal -> JSM a) -> value -> JSM (Maybe a) maybeNullOrUndefined' f value = do@@ -446,7 +422,6 @@             valIsUndefined rval >>= \case                 True -> return Nothing                 _    -> Just <$> f rval-{-# INLINE maybeNullOrUndefined' #-}  ----------- booleans --------------- -- | Make a JavaScript boolean value@@ -458,17 +433,14 @@     gctxt <- ask     liftIO (jsvaluemakeboolean gctxt b) >>= makeNewJSVal #endif-{-# INLINE valMakeBool #-}  -- | Make a JavaScript boolean value instance ToJSVal Bool where     toJSVal = valMakeBool-    {-# INLINE toJSVal #-}  -- | Makes an argument list with just a single JavaScript boolean value instance MakeArgs Bool where     makeArgs b = valMakeBool b >>= (\ref -> return [ref])-    {-# INLINE makeArgs #-}  ----------- numbers --------------- -- | Make a JavaScript number@@ -480,45 +452,35 @@     gctxt <- ask     liftIO (jsvaluemakenumber gctxt n) >>= makeNewJSVal #endif-{-# INLINE valMakeNumber #-}  -- | Makes a JavaScript number instance ToJSVal Double where     toJSVal = valMakeNumber-    {-# INLINE toJSVal #-}  instance ToJSVal Float where     toJSVal = valMakeNumber . realToFrac-    {-# INLINE toJSVal #-}  instance ToJSVal Word where     toJSVal = valMakeNumber . fromIntegral-    {-# INLINE toJSVal #-}  instance ToJSVal Word32 where     toJSVal = valMakeNumber . fromIntegral-    {-# INLINE toJSVal #-}  instance ToJSVal Word64 where     toJSVal = valMakeNumber . fromIntegral-    {-# INLINE toJSVal #-}  instance ToJSVal Int where     toJSVal = valMakeNumber . fromIntegral-    {-# INLINE toJSVal #-}  instance ToJSVal Int32 where     toJSVal = valMakeNumber . fromIntegral-    {-# INLINE toJSVal #-}  instance ToJSVal Int64 where     toJSVal = valMakeNumber . fromIntegral-    {-# INLINE toJSVal #-}  -- | Makes an argument list with just a single JavaScript number instance MakeArgs Double where     makeArgs n = valMakeNumber n >>= (\ref -> return [ref])-    {-# INLINE makeArgs #-}  -- | Make a JavaScript string from `Text` valMakeText :: Text -> JSM JSVal@@ -530,7 +492,6 @@     withJSString (textToStr text) $ \s ->         liftIO (jsvaluemakestring gctxt s) >>= makeNewJSVal #endif-{-# INLINE valMakeText #-}  -- | Make a JavaScript string from `JSString` valMakeString :: JSString -> JSM JSVal@@ -542,40 +503,32 @@     withJSString str $ \s ->         liftIO (jsvaluemakestring gctxt s) >>= makeNewJSVal #endif-{-# INLINE valMakeString #-}  -- | Makes a JavaScript string instance ToJSVal Text where     toJSVal = valMakeText-    {-# INLINE toJSVal #-}  -- | Makes an argument list with just a single JavaScript string instance MakeArgs Text where     makeArgs t = valMakeText t >>= (\ref -> return [ref])-    {-# INLINE makeArgs #-}  -- | Makes a JavaScript string instance ToJSVal String where     toJSVal = valMakeText . T.pack-    {-# INLINE toJSVal #-}  -- | Makes a JavaScript string instance ToJSVal JSString where     toJSVal = valMakeString-    {-# INLINE toJSVal #-}  -- | If we already have a JSString we are fine instance ToJSString JSString where     toJSString = id-    {-# INLINE toJSString #-}  instance ToJSString Text where     toJSString = textToStr-    {-# INLINE toJSString #-}  instance ToJSString String where     toJSString = textToStr . T.pack-    {-# INLINE toJSString #-}  -- | Derefernce a value reference. --@@ -653,12 +606,10 @@ -- | Makes a JavaScript value from a 'JSValue' ADT. instance ToJSVal JSValue where     toJSVal = valMakeRef-    {-# INLINE toJSVal #-}  -- | Makes an argument list with just a single JavaScript value from a 'JSValue' ADT. instance MakeArgs JSValue where     makeArgs v = valMakeRef v >>= (\ref -> return [ref])-    {-# INLINE makeArgs #-}  --instance MakeObjectRef JSNull where --    makeObjectRef _ = Object <$> valMakeNull
tests/DocTest.hs view
@@ -14,6 +14,11 @@     "-package=lens-" ++ VERSION_lens,     "-package=text-" ++ VERSION_text,     "-package=transformers-" ++ VERSION_transformers,+    "-package=haskell-gi-base-" ++ VERSION_haskell_gi_base,+    "-package=gi-glib-" ++ VERSION_gi_glib,+    "-package=gi-gtk-" ++ VERSION_gi_gtk,+    "-package=gi-webkit-" ++ VERSION_gi_webkit,+    "-package=gi-javascriptcore-" ++ VERSION_gi_javascriptcore,     "-isrc",     "src/Language/Javascript/JSaddle/Arguments.hs",     "src/Language/Javascript/JSaddle/Classes.hs",