mlms13 / bs-decode

Type-safe JSON decoding for ReasonML and OCaml
https://mlms13.github.io/bs-decode/docs/what-and-why
MIT License
103 stars 18 forks source link

Change the implementation of optional #131

Open mlms13 opened 1 year ago

mlms13 commented 1 year ago

Now that we have a null decoder, we can decode optional values as:

let optional =
  decoder => alt(null |> map(() => None), decoder |> map(Option.pure))

See #124