aboutsummaryrefslogtreecommitdiff
path: root/grammar
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2016-05-08 18:14:53 +0200
committerPierre-Marie Pédrot2016-05-08 18:14:53 +0200
commit9fe0471ef0127e9301d0450aacaeb1690abb82ad (patch)
tree6a244976f5caef6a2b88c84053fce87f94c78f96 /grammar
parenta6de02fcfde76f49b10d8481a2423692fa105756 (diff)
parent8d3f0b614d7b2fb30f6e87b48a4fc5c0d286e49c (diff)
Change the toplevel representation of Ltac values to an untyped one.
This brings the evaluation model of Ltac closer to those of usual languages, and further allows the integration of static typing in the long run. More precisely, toplevel constructed values such as lists and the like do not carry anymore the type of the underlying data they contain. This is mostly an API change, as it did not break any contrib outside of mathcomp.
Diffstat (limited to 'grammar')
-rw-r--r--grammar/argextend.ml422
1 files changed, 10 insertions, 12 deletions
diff --git a/grammar/argextend.ml4 b/grammar/argextend.ml4
index dca3e1656f..3b7e180c6f 100644
--- a/grammar/argextend.ml4
+++ b/grammar/argextend.ml4
@@ -88,6 +88,7 @@ let check_type prefix s = function
| Some _ -> warning_redundant prefix s
let declare_tactic_argument loc s (typ, f, g, h) cl =
+ let se = mlexpr_of_string s in
let rawtyp, rawpr, globtyp, globpr, typ, pr = match typ with
| `Uniform (typ, pr) ->
let typ = get_type "" s typ in
@@ -118,19 +119,21 @@ let declare_tactic_argument loc s (typ, f, g, h) cl =
let interp = match f with
| None ->
begin match globtyp with
- | None -> <:expr< fun ist v -> Ftactic.return v >>
+ | None ->
+ let typ = match globtyp with None -> ExtraArgType s | Some typ -> typ in
+ <:expr< fun ist v -> Ftactic.return (Geninterp.Val.inject (Geninterp.val_tag $make_topwit loc typ$) v) >>
| Some globtyp ->
<:expr< fun ist x ->
- Ftactic.bind
- (Tacinterp.interp_genarg ist (Genarg.in_gen $make_globwit loc globtyp$ x))
- (fun v -> Ftactic.return (Tacinterp.Value.cast $make_topwit loc globtyp$ v)) >>
+ Tacinterp.interp_genarg ist (Genarg.in_gen $make_globwit loc globtyp$ x) >>
end
| Some f ->
(** Compatibility layer, TODO: remove me *)
+ let typ = match globtyp with None -> ExtraArgType s | Some typ -> typ in
<:expr<
let f = $lid:f$ in
fun ist v -> Ftactic.nf_s_enter { Proofview.Goal.s_enter = fun gl ->
let (sigma, v) = Tacmach.New.of_old (fun gl -> f ist gl v) gl in
+ let v = Geninterp.Val.inject (Geninterp.val_tag $make_topwit loc typ$) v in
Sigma.Unsafe.of_pair (Ftactic.return v, sigma)
}
>> in
@@ -147,20 +150,15 @@ let declare_tactic_argument loc s (typ, f, g, h) cl =
| Some f -> <:expr< $lid:f$>> in
let dyn = match typ with
| None -> <:expr< None >>
- | Some typ ->
- if is_self s typ then <:expr< None >>
- else <:expr< Some (Genarg.val_tag $make_topwit loc typ$) >>
+ | Some typ -> <:expr< Some (Geninterp.val_tag $make_topwit loc typ$) >>
in
- let se = mlexpr_of_string s in
let wit = <:expr< $lid:"wit_"^s$ >> in
declare_str_items loc
- [ <:str_item<
- value ($lid:"wit_"^s$) =
- let dyn = $dyn$ in
- Genarg.make0 ?dyn $se$ >>;
+ [ <:str_item< value ($lid:"wit_"^s$) = Genarg.make0 $se$ >>;
<:str_item< Genintern.register_intern0 $wit$ $glob$ >>;
<:str_item< Genintern.register_subst0 $wit$ $subst$ >>;
<:str_item< Geninterp.register_interp0 $wit$ $interp$ >>;
+ <:str_item< Geninterp.register_val0 $wit$ $dyn$ >>;
make_extend loc s cl wit;
<:str_item< do {
Pptactic.declare_extra_genarg_pprule