-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic deriving #3
Conversation
@@ -37,6 +44,44 @@ import qualified Data.Map as Map | |||
class DecodeJson a where | |||
decodeJson :: Json -> Either String a | |||
|
|||
-- | Decode `Json` representation of a value which has a `Generic` type. | |||
gDecodeJson :: forall a. (Generic a) => Json -> Either String a | |||
gDecodeJson = map (fromJust <<< fromSpine) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should eliminate this fromJust
and instead return a Left
with some appropriate error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdegoes That's right. Fixed.
Looks great! Three minor nitpicks:
👍 Thanks for your work on this! |
@jdegoes Nitpicks are welcome.
|
(1) and (2) look fine. For (3), I meant, create a more complex data structure to exercise all the types exposed in Generic. |
@jdegoes Makes sense. Fixed. |
👍 Awesome work! Can you squash commits one more time and I'll merge in? |
Upps. Broke it while rebasing, fixing now. |
Ready to be merged now |
👍 Thanks again! |
@jdegoes Thanks for the review |
It should be quite ready now.