File tree Expand file tree Collapse file tree 3 files changed +5
-7
lines changed Expand file tree Collapse file tree 3 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -92,11 +92,6 @@ instance PFromJSVal Float where pFromJSVal x = F# (jsvalToFloat x)
9292instance 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-
10095instance PToJSVal JSVal where pToJSVal = id
10196 {-# INLINE pToJSVal #-}
10297instance PToJSVal JSString where pToJSVal = jsval
Original file line number Diff line number Diff line change @@ -3,13 +3,16 @@ module GHCJS.Nullable ( Nullable(..)
33 , maybeToNullable
44 ) where
55
6+ import GHCJS.Foreign (isTruthy )
67import GHCJS.Prim (JSVal (.. ))
78import GHCJS.Marshal.Pure (PToJSVal (.. ), PFromJSVal (.. ))
89
910newtype Nullable a = Nullable JSVal
1011
1112nullableToMaybe :: 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
1518maybeToNullable :: PToJSVal a => Maybe a -> Nullable a
Original file line number Diff line number Diff line change 11name : ghcjs-base
2- version : 0.2.0.0
2+ version : 0.2.0.1
33synopsis : base library for GHCJS
44homepage : http://github.com/ghcjs/ghcjs-base
55license : MIT
You can’t perform that action at this time.
0 commit comments