Skip to content

Commit 6328c2d

Browse files
committed
Removed PFromJSRef (Maybe a) instance
1 parent 85552b5 commit 6328c2d

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

GHCJS/Marshal/Pure.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ instance PFromJSVal Float where pFromJSVal x = F# (jsvalToFloat x)
9292
instance PFromJSVal Double where pFromJSVal x = D# (jsvalToDouble x)
9393
{-# INLINE pFromJSVal #-}
9494

95-
instance PFromJSVal a => PFromJSVal (Maybe a) where
96-
pFromJSVal x | isUndefined x || isNull x = Nothing
97-
pFromJSVal x = Just (pFromJSVal x)
98-
{-# INLINE pFromJSVal #-}
99-
10095
instance PToJSVal JSVal where pToJSVal = id
10196
{-# INLINE pToJSVal #-}
10297
instance PToJSVal JSString where pToJSVal = jsval

GHCJS/Nullable.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ module GHCJS.Nullable ( Nullable(..)
33
, maybeToNullable
44
) where
55

6+
import GHCJS.Foreign (isTruthy)
67
import GHCJS.Prim (JSVal(..))
78
import GHCJS.Marshal.Pure (PToJSVal(..), PFromJSVal(..))
89

910
newtype Nullable a = Nullable JSVal
1011

1112
nullableToMaybe :: PFromJSVal a => Nullable a -> Maybe a
12-
nullableToMaybe (Nullable r) = pFromJSVal r
13+
nullableToMaybe (Nullable r) = if (isTruthy r)
14+
then Just $ pFromJSVal r
15+
else Nothing
1316
{-# INLINE nullableToMaybe #-}
1417

1518
maybeToNullable :: PToJSVal a => Maybe a -> Nullable a

ghcjs-base.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: ghcjs-base
2-
version: 0.2.0.0
2+
version: 0.2.0.1
33
synopsis: base library for GHCJS
44
homepage: http://github.com/ghcjs/ghcjs-base
55
license: MIT

0 commit comments

Comments
 (0)