Created
September 9, 2014 21:04
-
-
Save supki/fa792f87d769d739650f to your computer and use it in GitHub Desktop.
EBLO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newtype FromJSON_ a = FromJSON_ { _parseJSON :: Value -> Parser a } | |
newtype T a s = T { unT :: a } | |
instance Reifies s (FromJSON_ a) => FromJSON (T a s) where | |
parseJSON = fmap T . _parseJSON (reflect (Proxy :: Proxy s)) | |
parseJson :: forall a. (Value -> Parser a) -> ByteString -> Maybe a | |
parseJson f b = reify (FromJSON_ f) (\(_ :: Proxy s) -> fmap unT ((decode :: ByteString -> Maybe (T a s)) b)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment