-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add codec for Js.Dict.t #48
Conversation
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.
Thanks for the contribution @jchavarri! Left a couple notes
@@ -16,6 +16,7 @@ open Belt.Result; */ | |||
[@decco] type l('a) = list('a); | |||
[@decco] type o('a) = option('a); | |||
[@decco] type r('v, 'e) = Belt.Result.t('v, 'e); | |||
[@decco] type d('v) = Js.Dict.t('v); |
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.
Could you write tests that use this type? Or give me permission to push?
src/Decco.re
Outdated
|
||
| (Ok(prev), Ok(newVal)) => prev->Belt.List.add((key, newVal))->Ok; | ||
} | ||
)->Belt.Result.map(Belt.List.toArray)->Belt.Result.map(Js.Dict.fromArray); |
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.
Instead of building a list, converting it to an array. and then converting that to a Js.Dict.t, how about using the reducer to build the Js.Dict.t directly?
Co-Authored-By: Ryan <rpbiwer@gmail.com>
…ating the initial value
@ryb73 thanks for the review :) I think I tackled all requests 👍 Do you mind taking another look please? Edit: regarding using arrays + lists to generate the new dict, I used them because |
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.
Sorry for the delay. Looks good!!
Muchisimas gracias, @jchavarri! |
Fixes #4.