Skip to content
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

Remove AsPrimitive and Primitive #47

Merged
merged 3 commits into from
Mar 10, 2022
Merged

Remove AsPrimitive and Primitive #47

merged 3 commits into from
Mar 10, 2022

Conversation

sjshuck
Copy link

@sjshuck sjshuck commented Mar 9, 2022

Fixes #26.

src/Data/Aeson/Lens.hs Outdated Show resolved Hide resolved
CHANGELOG.markdown Show resolved Hide resolved
@sjshuck
Copy link
Author

sjshuck commented Mar 10, 2022

I marked the containing convo resolved, but I want to echo my comment here for any follow-up:

Re-added [class constraint AsNumber t => AsValue t]. However, to me this reads as "everything I might want to discern as a Value, I might also want to discern as a Scientific", which I don't really understand from a practical perspective. Not that I have to.

@RyanGlScott
Copy link
Member

However, to me this reads as "everything I might want to discern as a Value, I might also want to discern as a Scientific", which I don't really understand from a practical perspective.

I guess I was thinking about it from a convenience perspective. That is, if you have an AsValue t constraint and want to get a Maybe Scientific out of it, then the superclass allows you to write x ^? _Number directly instead of the slightly less direct x ^? _Value._Number. A minor convenience, for sure, but a convenience nonetheless.

@sjshuck
Copy link
Author

sjshuck commented Mar 10, 2022

You can do that even without the class constraint. All the constraint seems to do is require any user who wants to make their own AsValue instance to first also make it an AsNumber instance.

@RyanGlScott
Copy link
Member

You can do that even without the class constraint.

Just to be sure we're talking about the same code, I have this scenario in mind:

f :: AsValue t => t -> Maybe Scientific
f x = x ^? _Number

That won't typecheck unless AsNumber is a superclass of AsValue, unless I'm missing something.

@sjshuck
Copy link
Author

sjshuck commented Mar 10, 2022

You're right, I only tested "42" ^? _Number, but that was merely using the AsNumber instance of a String. Thanks for clearing me up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Does anybody actually care about Primitive?
2 participants