You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to have distinction between absence of field and its null value.
dataBlah=Blah (Maybe (MaybeString))
instanceFromJSONBlahwhere
parseJSON (Object v) =Blah<$> v .:?"blah"
BlahNothing-- if field not mentionedBlah (JustNothing) -- if field has null value
However, the result of parsing is never Blah (Just Nothing) because .:? uses (Maybe a) instance directly.
(.:?):: (FromJSONa) =>Object->Text->Parser (Maybea)
obj .:? key =caseH.lookup key obj ofNothing->pureNothingJust v -> parseJSON v
-- Just v -> Just <$> parseJSON v would have expected behavior
This is committed as d0414be
However, it is not in the Changelog even though this is a huge breaking change.
I personally like the change, however, I think it may cause so much breakage that the existing behavior should be maintained and a different operator should be added instead., perhaps .:??
Activity
bos commentedon Sep 4, 2013
The obvious fix for this breaks some of the test suite, and I haven't had a chance to diagnose that yet. Looking.
bos commentedon Sep 4, 2013
cc @ffwng
Fix .:? behavior for haskell#83
Fix .:? behavior for haskell#83
Fix .:? behavior for haskell#83
Fix .:? behavior for #83
lykahb commentedon Aug 11, 2015
Writing a testcase was harder than I expected since monadic Parser does not play well with properties.
isExistingKeyJust :: Value -> Bool
isExistingKeyJust (Object obj) = all (\k -> isJust $ obj .:? k) $ H.keys obj -- does not typecheck
isExistingKeyJust _ = False
gregwebs commentedon Sep 5, 2015
This is committed as d0414be
However, it is not in the Changelog even though this is a huge breaking change.
I personally like the change, however, I think it may cause so much breakage that the existing behavior should be maintained and a different operator should be added instead., perhaps
.:??gregwebs commentedon Sep 21, 2015
Should this be closed now?