-
Notifications
You must be signed in to change notification settings - Fork 41
Either instance for IsForeign #32
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
Conversation
src/Data/Foreign/Class.purs
Outdated
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.
So this prefers the Right parse then? I think Left would be more common (aeson etc.)
Also, you can probably shorten this using <|>.
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.
Yup! My thinking is: Attempt to parse the thing we actually want, and if that fails, then attempt to parse the error case. If you have Either String SomeType then String would always succeed even if SomeType could have been parsed.
|
Thanks! |
|
The |
|
I think I would prefer to provide this as a function instead of an instance. |
|
I've implemented two of the functions, one Right biased and the other Left biased, and removed the instance. |
examples/Either.purs
Outdated
|
|
||
| main = do | ||
| print $ | ||
| readJSON """{ "x":1, "y": 2, "z": 3}""" :: F Response |
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.
How does this typecheck?
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.
It didn't, and neither psc-ide nor pulp -w build compile the examples directory so I forgot to change it.
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.
Ah ok, thought I was missing something 😄
No description provided.