aboutsummaryrefslogtreecommitdiff
path: root/vernac
diff options
context:
space:
mode:
authorHugo Herbelin2019-05-25 19:21:49 +0200
committerHugo Herbelin2019-06-16 14:04:19 +0200
commite034b4090ca45410853db60ae2a5d2f220b48792 (patch)
treec6f3476741850b4092c789f8bc9c8b3b2940b29d /vernac
parentf95017c2c69ee258ae570b789bce696357d2c365 (diff)
Turning "manual_implicits" into a list of position in impargs.ml.
Diffstat (limited to 'vernac')
-rw-r--r--vernac/classes.ml3
-rw-r--r--vernac/comAssumption.ml4
-rw-r--r--vernac/comDefinition.ml24
-rw-r--r--vernac/comFixpoint.ml2
-rw-r--r--vernac/comInductive.ml10
-rw-r--r--vernac/lemmas.ml2
-rw-r--r--vernac/record.ml14
7 files changed, 25 insertions, 34 deletions
diff --git a/vernac/classes.ml b/vernac/classes.ml
index b64af52b6e..bd5a211f1d 100644
--- a/vernac/classes.ml
+++ b/vernac/classes.ml
@@ -537,8 +537,7 @@ let interp_instance_context ~program_mode env ctx ~generalize pl tclass =
in
let sigma, (impls, ((env', ctx), imps)) = interp_context_evars ~program_mode env sigma ctx in
let sigma, (c', imps') = interp_type_evars_impls ~program_mode ~impls env' sigma tclass in
- let len = Context.Rel.nhyps ctx in
- let imps = imps @ Impargs.lift_implicits len imps' in
+ let imps = imps @ imps' in
let ctx', c = decompose_prod_assum sigma c' in
let ctx'' = ctx' @ ctx in
let (k, u), args = Typeclasses.dest_class_app (push_rel_context ctx'' env) sigma c in
diff --git a/vernac/comAssumption.ml b/vernac/comAssumption.ml
index c1f676b043..a27c08d176 100644
--- a/vernac/comAssumption.ml
+++ b/vernac/comAssumption.ml
@@ -283,8 +283,8 @@ let context poly l =
Classes.declare_instance env sigma (Some Hints.empty_hint_info) true (ConstRef cst);
status
else
- let test {CAst.v = (x, _)} = match x with
- | Constrexpr.ExplByPos (_, Some id') -> Id.equal id id'
+ let test x = match x.CAst.v with
+ | Some (Name id',_) -> Id.equal id id'
| _ -> false
in
let impl = List.exists test impls in
diff --git a/vernac/comDefinition.ml b/vernac/comDefinition.ml
index 01274e2568..ae1f55acda 100644
--- a/vernac/comDefinition.ml
+++ b/vernac/comDefinition.ml
@@ -30,16 +30,16 @@ let warn_implicits_in_term =
strbrk "Discarding incompatible declaration in term.")
let check_imps ~impsty ~impsbody =
- let impsty = List.map (fun x -> x.CAst.v) impsty in
- List.iter (fun {CAst.v = (key, (va:bool*bool*bool)); CAst.loc} ->
- let b =
- try
- (* Pervasives.(=) is OK for this type *)
- Pervasives.(=) (List.assoc_f Constrexpr_ops.explicitation_eq key impsty) va
- with Not_found -> false
- in
- if not b then warn_implicits_in_term ?loc ())
- impsbody
+ let rec aux impsty impsbody =
+ match impsty, impsbody with
+ | a1 :: impsty, a2 :: impsbody ->
+ (match a1.CAst.v, a2.CAst.v with
+ | None , None -> aux impsty impsbody
+ | Some _ , Some _ -> aux impsty impsbody
+ | _, _ -> warn_implicits_in_term ?loc:a2.CAst.loc ())
+ | _ :: _, [] | [], _ :: _ -> (* Information only on one side *) ()
+ | [], [] -> () in
+ aux impsty impsbody
let interp_definition ~program_mode pl bl poly red_option c ctypopt =
let env = Global.env() in
@@ -57,11 +57,11 @@ let interp_definition ~program_mode pl bl poly red_option c ctypopt =
match tyopt with
| None ->
let evd, (c, impsbody) = interp_constr_evars_impls ~program_mode ~impls env_bl evd c in
- evd, c, imps1@Impargs.lift_implicits (Context.Rel.nhyps ctx) impsbody, None
+ evd, c, imps1@impsbody, None
| Some (ty, impsty) ->
let evd, (c, impsbody) = interp_casted_constr_evars_impls ~program_mode ~impls env_bl evd c ty in
check_imps ~impsty ~impsbody;
- evd, c, imps1@Impargs.lift_implicits (Context.Rel.nhyps ctx) impsty, Some ty
+ evd, c, imps1@impsty, Some ty
in
(* Do the reduction *)
let evd, c = red_constant_body red_option env_bl evd c in
diff --git a/vernac/comFixpoint.ml b/vernac/comFixpoint.ml
index 6068cd90f1..0d7ba69955 100644
--- a/vernac/comFixpoint.ml
+++ b/vernac/comFixpoint.ml
@@ -197,7 +197,7 @@ let interp_recursive ~program_mode ~cofix fixl notations =
let fixtypes = List.map2 build_fix_type fixctxs fixccls in
let fixtypes = List.map (fun c -> nf_evar sigma c) fixtypes in
let fiximps = List.map3
- (fun ctximps cclimps (_,ctx) -> ctximps@(Impargs.lift_implicits (Context.Rel.nhyps ctx) cclimps))
+ (fun ctximps cclimps (_,ctx) -> ctximps@cclimps)
fixctximps fixcclimps fixctxs in
let sigma, rec_sign =
List.fold_left2
diff --git a/vernac/comInductive.ml b/vernac/comInductive.ml
index e0f2f05fe3..2f8b12f4c5 100644
--- a/vernac/comInductive.ml
+++ b/vernac/comInductive.ml
@@ -375,8 +375,7 @@ let interp_mutual_inductive_gen env0 ~template udecl (uparamsl,paramsl,indl) not
let env_ar_params = EConstr.push_rel_context ctx_params env_ar in
(* Compute interpretation metadatas *)
- let indimpls = List.map (fun impls -> userimpls @
- lift_implicits (Context.Rel.nhyps ctx_params) impls) indimpls in
+ let indimpls = List.map (fun impls -> userimpls @ impls) indimpls in
let impls = compute_internalization_env env_uparams sigma ~impls (Inductive (params,true)) indnames fullarities indimpls in
let ntn_impls = compute_internalization_env env_uparams sigma (Inductive (params,true)) indnames fullarities indimpls in
let mldatas = List.map2 (mk_mltype_data sigma env_params params) arities indnames in
@@ -402,8 +401,8 @@ let interp_mutual_inductive_gen env0 ~template udecl (uparamsl,paramsl,indl) not
constructors
in
let ctx_params = ctx_params @ ctx_uparams in
- let userimpls = useruimpls @ (lift_implicits (Context.Rel.nhyps ctx_uparams) userimpls) in
- let indimpls = List.map (fun iimpl -> useruimpls @ (lift_implicits (Context.Rel.nhyps ctx_uparams) iimpl)) indimpls in
+ let userimpls = useruimpls @ userimpls in
+ let indimpls = List.map (fun iimpl -> useruimpls @ iimpl) indimpls in
let fullarities = List.map (fun c -> EConstr.it_mkProd_or_LetIn c ctx_uparams) fullarities in
let env_ar = push_types env0 indnames relevances fullarities in
let env_ar_params = EConstr.push_rel_context ctx_params env_ar in
@@ -450,10 +449,9 @@ let interp_mutual_inductive_gen env0 ~template udecl (uparamsl,paramsl,indl) not
indl arities arityconcl constructors
in
let impls =
- let len = Context.Rel.nhyps ctx_params in
List.map2 (fun indimpls (_,_,cimpls) ->
indimpls, List.map (fun impls ->
- userimpls @ (lift_implicits len impls)) cimpls) indimpls constructors
+ userimpls @ impls) cimpls) indimpls constructors
in
let variance = if poly && cum then Some (InferCumulativity.dummy_variance uctx) else None in
(* Build the mutual inductive entry *)
diff --git a/vernac/lemmas.ml b/vernac/lemmas.ml
index a7366b2c56..7aba64fb93 100644
--- a/vernac/lemmas.ml
+++ b/vernac/lemmas.ml
@@ -469,7 +469,7 @@ let start_lemma_com ~program_mode ?inference_hook ?hook kind thms =
(* XXX: The nf_evar is critical !! *)
evd, (id.CAst.v,
(Evarutil.nf_evar evd (EConstr.it_mkProd_or_LetIn t' ctx),
- (ids, imps @ lift_implicits (Context.Rel.nhyps ctx) imps'))))
+ (ids, imps @ imps'))))
evd thms in
let recguard,thms,snl = look_for_possibly_mutual_statements evd thms in
let evd = Evd.minimize_universes evd in
diff --git a/vernac/record.ml b/vernac/record.ml
index e555c6d154..48cde133a8 100644
--- a/vernac/record.ml
+++ b/vernac/record.ml
@@ -476,21 +476,15 @@ let declare_structure ~cum finite ubinders univs paramimpls params template ?(ki
List.mapi map record_data
let implicits_of_context ctx =
- List.map_i (fun i name ->
- let explname =
- match name with
- | Name n -> Some n
- | Anonymous -> None
- in CAst.make (ExplByPos (i, explname), (true, true, true)))
- 1 (List.rev (Anonymous :: (List.map RelDecl.get_name ctx)))
+ List.map (fun name -> CAst.make (Some (name,true)))
+ (List.rev (Anonymous :: (List.map RelDecl.get_name ctx)))
let declare_class def cum ubinders univs id idbuild paramimpls params arity
template fieldimpls fields ?(kind=StructureComponent) coers priorities =
let fieldimpls =
(* Make the class implicit in the projections, and the params if applicable. *)
- let len = List.length params in
let impls = implicits_of_context params in
- List.map (fun x -> impls @ Impargs.lift_implicits (succ len) x) fieldimpls
+ List.map (fun x -> impls @ x) fieldimpls
in
let binder_name = Namegen.next_ident_away id (Termops.vars_of_env (Global.env())) in
let data =
@@ -704,7 +698,7 @@ let definition_structure udecl kind ~template cum poly finite records =
declare_class def cum ubinders univs id.CAst.v idbuild
implpars params arity template implfs fields coers priorities
| _ ->
- let map impls = implpars @ Impargs.lift_implicits (succ (List.length params)) impls in
+ let map impls = implpars @ [CAst.make None] @ impls in
let data = List.map (fun (arity, implfs, fields) -> (arity, List.map map implfs, fields)) data in
let map (arity, implfs, fields) (is_coe, id, _, cfs, idbuild, _) =
let coe = List.map (fun (_, { rf_subclass ; rf_canonical }) ->