Value patterns match on a value (the result of computation), while
computation patterns handle the effects (hint hint) of
a computation. The only forms of computation patterns in OCaml today
are value patterns and exception patterns (exception p).
The sub-pattern `p` of the `lazy p` construction should be
a computation pattern, rather than a value pattern. This pull-request
does not make this change.
Most of the changes in this PR are boilerplate -- it really is a lot
of work now to add a new syntactic category to the typed-tree
syntax. This boilerplate is fairly automatic and should be easy to
review.
There is a subtle part to the patch, though: the implementation of the
pattern type-checking. It now has to reconstruct the value/computation
distinction (absent from the parse-tree), and return values from two
different types. Instead of splitting the type-checker in several
functions (which risked code duplications), I choose to use a GADT to
have the same [type_pat] function return two different types depending
on the caller. This is the least invasive way to adapt this part of
the codebase, whose inherent complexity is so large (unfortunately)
that adding a GADT to the mix barely makes a difference.
* MPR#7472: create .cmi files atomically
This is done by writing the data to a temporary file, compute the checksum, finish writing the data, and only then rename the temporary file to the destination .cmi file.
Writing .cmi files this way should avoid the corruption of .cmi files reported in MPR#4991. This corruption can occur when a .cmi file is produced simultaneously by a run of ocamlc and a run of ocamlopt.
"Atomic" here means "as atomic as the underlying file system guarantees". The atomicity guarantees of Windows file systems aren't entirely clear.
* Create .annot and .cmt files atomically, like .cmi files
Follow-up to MPR#7472. The pattern "write to temporary file then rename"
is abstracted in the new function Misc.output_to_file_via_temporary
and applied to .cmi, .cmt and .annot files.