You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I finally understood why we have type 'f field = field in a bunch of places : D
Basically if you have a type field in your interface, and use this field everywhere in the interface (e.g. val thing : t -> field) then you can't apply that interface to a module that's generic over a field.
So for example, I'm writing my interface for Cvars with an abstract type field:
module type Cvar_intf=sigtypefieldtypet [@@deriving sexp]valto_constant_and_terms : t -> fieldoption* (field*int) list(* and so on... *)
which I can't. Using a type type 'f field is the only solution for an interface that can be apply to both a generic implementation (over a field in this case) and an instantiated implementation (where the field is known to be Backend.Field.t for example).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I finally understood why we have type 'f field = field in a bunch of places : D
Basically if you have a type
field
in your interface, and use thisfield
everywhere in the interface (e.g.val thing : t -> field
) then you can't apply that interface to a module that's generic over a field.So for example, I'm writing my interface for
Cvar
s with an abstracttype
field:but if I want to apply it to my module
T
:I can't. I want to be able to write this:
which I can't. Using a type
type 'f field
is the only solution for an interface that can be apply to both a generic implementation (over a field in this case) and an instantiated implementation (where the field is known to beBackend.Field.t
for example).Beta Was this translation helpful? Give feedback.
All reactions