1. 11
  1.  

  2. 2

    decodeWord hurts to read. Old OCaml supported by BuckleScript doesn’t have an option monad in its standard library, but its implementation is literally a single line. ;)

    User-defined do notation (let+ etc.) from 4.08 would make it even easier to read, but even plain old x >>= (fun words -> ...) would be an improvement.

    1. 1

      In production we would most likely use a PPX to generate the decoder, e.g. https://github.com/reasonml-labs/decco . In any case let-operators should land in BuckleScript (Reason syntax only, though) hopefully soon (there’s an open PR). Oh, and BuckleScript ships with an option monad (it was even used in the post itself).