squiggle/src/distPlus/expressionTree/Mathjs.re

10 lines
355 B
ReasonML
Raw Normal View History

[@bs.module "./MathjsWrapper.js"]
2020-03-24 00:04:48 +00:00
external parseMathExt: string => Js.Json.t = "parseMath";
let parseMath = (str: string): result(Js.Json.t, string) =>
switch (parseMathExt(str)) {
| exception (Js.Exn.Error(err)) =>
Error(Js.Exn.message(err) |> E.O.default("MathJS Parse Error"))
| exception _ => Error("MathJS Parse Error")
| j => Ok(j)
};