Module Js_cast

Safe cast between OCaml values which share the same runtime representation

Different OCaml types might share the same represention in the Melange runtime; while this is a compiler internal knowledge, applications might benefit from having a safe and zero cost conversion between those types.

This modules acts as the single place for such conversion.

If for any reason, the runtime representation changes, those function will be modified accordingly.

let intOfBool: bool => int;

intOfBool b returns 1 for when b is true and 0 when b is false

let floatOfInt: int => float;

floatOfInt i returns the float value of i