packages feed

javascript-extras 0.3.1.0 → 0.3.2.0

raw patch · 2 files changed

+10/−6 lines, 2 filesdep ~javascript-extrasPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: javascript-extras

API changes (from Hackage documentation)

- JavaScript.Extras.Property: getProperty :: JSString -> JSVal -> IO JSVar
+ JavaScript.Extras.Property: getProperty :: Coercible a JSVal => JSString -> a -> IO JSVar
- JavaScript.Extras.Property: setProperty :: Property -> JSVal -> IO ()
+ JavaScript.Extras.Property: setProperty :: Coercible a JSVal => Property -> a -> IO ()

Files

javascript-extras.cabal view
@@ -1,5 +1,5 @@ name:                javascript-extras-version:             0.3.1.0+version:             0.3.2.0 synopsis:            Extra javascript functions when using GHCJS description:         Extra javascript functions when using GHCJS homepage:            https://github.com/louispan/javascript-extras#readme@@ -39,7 +39,7 @@   ghc-options:         -Wall -threaded -rtsopts -with-rtsopts=-N   cpp-options:         -DGHCJS_BROWSER   build-depends:       base >= 4.7 && < 5-                     , javascript-extras >= 0.3.1+                     , javascript-extras   default-language:    Haskell2010   default-extensions:  ApplicativeDo   if impl(ghcjs)
src/JavaScript/Extras/Property.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GHCForeignImportPrim #-}  module JavaScript.Extras.Property@@ -11,6 +12,7 @@  import Control.DeepSeq import Control.Parallel+import Data.Coerce import qualified GHC.Exts as Exts import qualified GHCJS.Marshal.Pure as J import qualified GHCJS.Types as J@@ -22,16 +24,18 @@ type Property = (J.JSString, JE.JSVar)  -- | get a property of any JSVal. If a null or undefined is queried, the result will also be null-getProperty :: J.JSString -> J.JSVal -> IO JE.JSVar-getProperty k x = let k' = J.pToJSVal k+getProperty :: Coercible a J.JSVal => J.JSString -> a -> IO JE.JSVar+getProperty k a = let k' = J.pToJSVal k+                      x = coerce a                   in if J.isUndefined x || J.isNull x                          || J.isUndefined k' || J.isNull k'                      then pure $ JE.JSVar J.nullRef                      else js_unsafeGetProperty k x  -- | set a property of any JSVal-setProperty :: Property -> J.JSVal -> IO ()-setProperty (k, v) x = let k' = J.pToJSVal k+setProperty :: Coercible a J.JSVal => Property -> a -> IO ()+setProperty (k, v) a = let k' = J.pToJSVal k+                           x = coerce a                     in if J.isUndefined x || J.isNull x                           || J.isUndefined k' || J.isNull k'                        then pure ()