0

Map.String does not work in ReScript so I am using Belt.Map.String instead but it doesn't have "add" method is there a replacement for it if not what can I use instead Belt.Map.String?

let getAllResponseHeadersAsDict = (x: t): Tea_result.t<Map.String.t<string>, errors> => {
  module StringMap = Map.String
  switch getAllResponseHeadersAsList(x) {
  | Tea_result.Error(_) as err => err
  | Tea_result.Ok(l) =>
    let insert = (d, (k, v)) => StringMap.add(k, v, d)
    Tea_result.Ok(List.fold_left(insert, StringMap.empty, l))
  }
}
let getAllResponseHeadersAsDict = (x: t): Tea_result.t<Belt.Map.String.t<string>, errors> => {
  module StringMap = Belt.Map.String
    ...
}

I have tried to use Map.Make(String) instead of Belt.Map.String

module StringMap = Map.Make(String)

but I had errors in the return type (this does not work Map.Make(String).t as a return type)

Any idea on how this can be solved? Thank you

Fer iel
  • 23
  • 4
  • There's a [`set`](https://rescript-lang.org/docs/manual/latest/api/belt/map-string#set) function. Is that not equivalent? – glennsl Aug 13 '22 at 14:28
  • I have tried it (let insert = (d, (k, v)) => StringMap.set(d,k, v)) there are no errors but I was not sure if it is equivalent. – Fer iel Aug 13 '22 at 14:57
  • I don't know what the original actually refers to, but the possibility space here seems rather limited, so I think it's safe to assume it is. – glennsl Aug 13 '22 at 15:56

0 Answers0