forked from statusfailed/aeson-traversal
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Consider offering a Prism
into an Object
's KeyMap
#38
Comments
Closed
RyanGlScott
added a commit
that referenced
this issue
Oct 9, 2021
`aeson-2.0.0.0` changes `Object`'s field from a `HashMap` to a new `KeyMap` type. This patch adapts `lens-aeson` to the new API. h/t to phadej/aeson-optics@ff31ca0, on which I based this patch. We may want to consider changing the type of `_Object` later (#38), but that should probably wait until we can depend on `aeson >= 2` unconditionally. Fixes #37.
RyanGlScott
added a commit
that referenced
this issue
Oct 9, 2021
`aeson-2.0.0.0` changes `Object`'s field from a `HashMap` to a new `KeyMap` type. This patch adapts `lens-aeson` to the new API. h/t to phadej/aeson-optics@ff31ca0, on which I based this patch. We may want to consider changing the type of `_Object` later (#38), but that should probably wait until we can depend on `aeson >= 2` unconditionally. Fixes #37.
RyanGlScott
added a commit
that referenced
this issue
Oct 9, 2021
`aeson-2.0.0.0` changes `Object`'s field from a `HashMap` to a new `KeyMap` type. This patch adapts `lens-aeson` to the new API. h/t to phadej/aeson-optics@ff31ca0, on which I based this patch. We may want to consider changing the type of `_Object` later (#38), but that should probably wait until we can depend on `aeson >= 2` unconditionally. Fixes #37.
FWIW, I'm in favor of (2), namely redefining _Object :: AsValue t => Prism' t Object since
|
Now that Stackage Nightly includes |
RyanGlScott
added a commit
that referenced
this issue
Mar 7, 2022
In `aeson-2.0.*`, `Object`'s field is of type `KeyMap Value` rather than `HashMap Text Value`. Now that Stackage Nightly includes `aeson-2.0.*`, it's high time that we updated the `lens-aeson` API to mirror this change. This most notably affects the type of `_Object`, which also requires updating the types of `key` and `members` as a consequence. In order to make the doctests continue to work, I found myself needing to add `Wrapped` and `Rewrapped` instances for `KeyMap`. In these instances, I treat `KeyMap v` as a wrapper around `[(Key, v)]`, where the order of the key-value pairs in the list is not stable. Fixes #38.
See #42. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In
aeson-2.0.0.0
and later,Object
uses aKeyMap
rather than directly exposing aHashMap
. See haskell/aeson#866. In light of this, the current type of_Object
(Prism' t (HashMap Text Value)
) is not ideal—ideally, it would focus on aKeyMap
instead. Some possibilities are:_Object
's type as is, but offer another method of typePrism' t (KeyMap Value)
alongside it. (_ObjectKeyMap
, perhaps?)_Object
toPrism' t (KeyMap Value)
. This would require a breaking API change.Either option will likely require waiting a bit until we can require
aeson >= 2
unconditionally.The text was updated successfully, but these errors were encountered: