Closed riaqn closed 1 week ago
I did most of the suggestions by @lpw25 except the following:
Mode.Modality.Value.Const.to_list
instead of returning the list of atom modalities, it should return a record of atom modalities, each field corresponding to an axis. I argue that the current interface allows printtyp.ml
to not mention specific axes.val infer: mmode:Value.lr -> mode:Value.l -> t
can split the argument mmode:lr
into a left and a right corresponding to monadic and comonadic fragments. The reality is more messy. In short, the monadic fragments needs both left
and right
for better types. See cross
in mode.ml
.This is now ready for review. Please review the whole PR in one go - the commits are for my own tracking.
The feature needs to be enabled by -extension mode_alpha
. When it's disabled:
val f : t @@ m
- will trigger error.struct let f = ... end
, the inferred modalities are fixed to be identity.cmi
built with -extension mode_alpha
, the modalities in there will work as usual.The above decision is driven by the example:
module M = struct let f x = x end
module M' = struct let (f @ nonportable) x = x end
For early adopters, the printed module types should be different; And that means the first should read sig val f : 'a -> 'a @@ portable
while the second doesn't. However, for a normal user, finding val_modalities
popping out from nowhere will be confusing. So we will use -extension mode_alpha
to switch the behaviour.
This PR allows values in structures to have modalities.