mirror of
https://github.com/github/semantic.git
synced 2024-12-19 04:41:47 +03:00
Use fromMaybes to clean up the FromJSON instance for BlobPair.
This commit is contained in:
parent
fc93bb4b4d
commit
fecb0d8f1f
@ -105,11 +105,7 @@ instance FromJSON BlobPair where
|
||||
parseJSON = withObject "BlobPair" $ \o -> do
|
||||
before <- o .:? "before"
|
||||
after <- o .:? "after"
|
||||
case (before, after) of
|
||||
(Just b, Just a) -> pure $ Compare b a
|
||||
(Just b, Nothing) -> pure $ Delete b
|
||||
(Nothing, Just a) -> pure $ Insert a
|
||||
_ -> Prelude.fail "Expected object with 'before' and/or 'after' keys only"
|
||||
maybeM (Prelude.fail "Expected object with 'before' and/or 'after' keys only") (fromMaybes before after)
|
||||
|
||||
maybeBlobPair :: MonadFail m => Maybe Blob -> Maybe Blob -> m BlobPair
|
||||
maybeBlobPair a b = case (a, b) of
|
||||
|
Loading…
Reference in New Issue
Block a user