summaryrefslogtreecommitdiff
path: root/language/l2_rules.ott
diff options
context:
space:
mode:
authorAlasdair Armstrong2018-02-06 00:46:33 +0000
committerAlasdair Armstrong2018-02-06 00:46:33 +0000
commit9a8abcb2a327e0ab3133b72c10959ca70bacd211 (patch)
tree00ee7920cd375af2e47072a2ae16538d69827325 /language/l2_rules.ott
parentfc5ad2e3930b06a8bd382639361b31bd7407f395 (diff)
Improve destructuring existential types
Make destructuring existentials less arcane by allowing them to be destructured via type patterns (typ_pat in ast.ml). This allows the following code for example: val mk_square : unit -> {'n 'm, 'n = 'm. vector('n, dec, vector('m, dec, bit))} function test (() : unit) -> unit = { let matrix as vector('width, _, 'height) = mk_square (); _prove(constraint('width = 'height)); () } where 'width we become 'n from mk_square, and 'height becomes 'm. The old syntax let vector as 'length = ... or even let 'vector = ... still works under this new scheme in a uniform way, so this is backwards compatible The way this works is when a kind identifier in a type pattern is bound against a type, e.g. 'height being bound against vector('m, dec, bit) in the example, then we get a constraint that 'height is equal to the first and only n-expression in the type, in this case 'm. If the type has two or more n-expressions (or zero) then this is a type error.
Diffstat (limited to 'language/l2_rules.ott')
0 files changed, 0 insertions, 0 deletions