vAccel RPC protocol in pure OCaml
0

Configure Feed

Select the types of activity you want to include in your feed.

genop: give arg_type its own equality

The wire round-trip test compared argument types with the polymorphic
(=), walking the representation of a type it does not own. Export
equal_arg_type and call it. An argument type is a flat enum of
thirty-two constructors whose only payload is an int32, so structural
equality is the equality here and it is defined as a monomorphic (=):
spelling the branches out by hand could only diverge from it.

+10 -1
+5
lib/genop.ml
··· 31 31 | Custom 32 32 | Other_arg_type of int32 33 33 34 + (* An argument type is a flat enum whose only payload is an int32, so 35 + structural equality is the equality here. Spelling out thirty-two 36 + constructors by hand could only diverge from it. *) 37 + let equal_arg_type : arg_type -> arg_type -> bool = ( = ) 38 + 34 39 let int_of_arg_type = function 35 40 | Raw -> 0l 36 41 | Int8 -> 1l
+3
lib/genop.mli
··· 39 39 | Custom 40 40 | Other_arg_type of int32 41 41 42 + val equal_arg_type : arg_type -> arg_type -> bool 43 + (** Structural equality on argument types. *) 44 + 42 45 val int_of_arg_type : arg_type -> int32 43 46 (** [int_of_arg_type ty] is the [genop.proto] wire value of [ty]. *) 44 47
+2 -1
test/test_genop.ml
··· 83 83 let wire = Protobuf.to_string Genop.arg_codec a in 84 84 let a' = Result.get_ok (Protobuf.of_string Genop.arg_codec wire) in 85 85 Alcotest.(check bool) 86 - (Fmt.str "arg type %ld" n) true (a'.Genop.arg_type = ty)) 86 + (Fmt.str "arg type %ld" n) true 87 + (Genop.equal_arg_type a'.Genop.arg_type ty)) 87 88 all; 88 89 Alcotest.(check int) "all 30 named types" 30 (List.length all) 89 90