Closed mlms13 closed 5 years ago
Naming crisis averted: we can call the decode function stringMap
to avoid the collision with the map: (a -> b) -> f a -> f b
function. Seems like we should be able to implement this using something like:
let stringMap = decodeInner =>
dict(decodeInner)
|> map(Js.Dict.entries)
|> map(Array.foldLeft(
(acc, (key, val)) =>
Map.String.set(key, val, acc),
Map.String.empty
);
For simple
Belt.Map
types with string keys, we can reuse thedict
decoder and convert pretty easily, but it would also be nice to take acompare
function and a key decoder and return aMap
with whatever key type you want (e.g. aMap
where the keys are dates).