Open mrmr1993 opened 3 years ago
The example functor returns a versioned type, which the ppx lint rules currently reject.
It's fine, in fact.
Making these changes requires a hard fork, since the version byte in serializations introduced by the versioned Poly
will disappear (which is a good thing).
We should probably "version" these functors (Poly_V1
, etc.), since the functors may differ when creating versioned types.
Making these changes requires a hard fork, since the version byte in serializations introduced by the versioned
Poly
will disappear (which is a good thing).
Completely agree, and looking forward to this 😁
We should probably "version" these functors (
Poly_V1
, etc.), since the functors may differ when creating versioned types.
I'm not sure how necessary that is if we expand the aliases, since the linter will be able to check the actual structure of the type when it's expanded. (If ocaml/ocaml#10777 is considered for merge, we might be able to achieve this with polys instead of functors too, but I don't expect that any time soon.)
I'm not sure how necessary that is if we expand the aliases
Right, if we keep around older versions, we may need multiple Poly
functors, and it would be good to have a systematic way to distinguish them.
We should have a standard module type name for the functor arguments, like Poly_arg
. Unfortunately, the actual type will differ from case to case, because of the deriving contents, so we can't declare such a type once and for all. For Account.t, a signature that works is
sig
type t [@@deriving sexp, equal, compare, hash, yojson]
end
We could use a ppx like:
[%%sig_type_derives sexp, equal, compare, hash, json]
to create such module types. We could also have the functor version number as an argument.
In types that are used by snarky, we've historically used a type variable for each type appearing in a field. These type variables are never actually useful to us, make type errors hard to read, and make type discovery far more opaque.
To get the same level of field sharing, we should consider converting e.g.
to use functors to give concrete types
Of particular benefit are:
MerlinTypeOf
in your editor of choice will tell you about the record's fields and their types directly{Protocol_state.Poly.genesis_state_hash= ...; ...}
)Poly
functor