summaryrefslogtreecommitdiff
path: root/interp/genintern.ml
blob: 7795946d56dd1f8de44fae94eed287ef4f7939d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
(************************************************************************)
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
(* <O___,, *   INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2015     *)
(*   \VV/  **************************************************************)
(*    //   *      This file is distributed under the terms of the       *)
(*         *       GNU Lesser General Public License Version 2.1        *)
(************************************************************************)

open Names
open Mod_subst
open Genarg

type glob_sign = {
  ltacvars : Id.Set.t;
  genv : Environ.env }

type ('raw, 'glb) intern_fun = glob_sign -> 'raw -> glob_sign * 'glb
type 'glb subst_fun = substitution -> 'glb -> 'glb

module InternObj =
struct
  type ('raw, 'glb, 'top) obj = ('raw, 'glb) intern_fun
  let name = "intern"
  let default _ = None
end

module SubstObj =
struct
  type ('raw, 'glb, 'top) obj = 'glb subst_fun
  let name = "subst"
  let default _ = None
end

module Intern = Register (InternObj)
module Subst = Register (SubstObj)

let intern = Intern.obj
let register_intern0 = Intern.register0

let generic_intern ist v =
  let unpacker wit v =
    let (ist, v) = intern wit ist (raw v) in
    (ist, in_gen (glbwit wit) v)
  in
  unpack { unpacker; } v

(** Substitution functions *)

let substitute = Subst.obj
let register_subst0 = Subst.register0

let generic_substitute subs v =
  let unpacker wit v = in_gen (glbwit wit) (substitute wit subs (glb v)) in
  unpack { unpacker; } v

let () = Hook.set Detyping.subst_genarg_hook generic_substitute