40 ms·
Where possible, I prefer making the syntax opt-in, and explicitly so. For example, stealing OCaml's syntax: let check_exp (g : Elliptic_curve_pt.t) (x : int) (
by mrmr1993 6y ago
Where possible, I prefer making the syntax opt-in, and explicitly so. For example, stealing OCaml's syntax:
let check_exp (g : Elliptic_curve_pt.t) (x : int) (y : int) =
let xy = x * y in
let open Elliptic_curve_pt.Num_syntax in
(g ^ x) ^ y = g ^ xy
This lets you avoid making hard decisions about what can be added/multiplied/etc. at the language level -- can a list of numbers representing the coefficients of a polynomial be added? -- without jumping to the extreme of allowing anything implicitly. This also lets the typechecker catch more of your mistakes by having stricter types, and means you know exactly where to go to find out what the syntax is encoding.
- a-nikolaev 6y agoI think, you could also write Elliptic_curve_pt.Num_syntax.( (g ^ x) ^ y = g ^ xy ) instead of let open Elliptic_curve_pt.Num_syntax in ...