| 1 | (************************************************************************) |
| 2 | (* * The Rocq Prover / The Rocq Development Team *) |
| 3 | (* v * Copyright INRIA, CNRS and contributors *) |
| 4 | (* <O___,, * (see version control and CREDITS file for authors & dates) *) |
| 5 | (* \VV/ **************************************************************) |
| 6 | (* // * This file is distributed under the terms of the *) |
| 7 | (* * GNU Lesser General Public License Version 2.1 *) |
| 8 | (* * (see LICENSE file for the text of the license) *) |
| 9 | (************************************************************************) |
| 10 | |
| 11 | (** This module defines potentially focussing tactics. They are used by Ltac to |
| 12 | emulate the historical behaviour of always-focussed tactics while still |
| 13 | allowing to remain global when the goal is not needed. *) |
| 14 | |
| 15 | type +'a focus |
| 16 | |
| 17 | type +'a t = 'a focus Proofview.tactic |
| 18 | (** The type of focussing tactics. A focussing tactic is like a normal tactic, |
| 19 | except that it is able to remember it have entered a goal. Whenever this is |
| 20 | the case, each subsequent effect of the tactic is dispatched on the |
| 21 | focused goals. This is a monad. *) |
| 22 | |
| 23 | (** {5 Monadic interface} *) |
| 24 | |
| 25 | val return : 'a -> 'a t |
| 26 | (** The unit of the monad. *) |
| 27 | |
| 28 | val bind : 'a t -> ('a -> 'b t) -> 'b t |
| 29 | (** The bind of the monad. *) |
| 30 | |
| 31 | (** {5 Operations} *) |
| 32 | |
| 33 | val lift : 'a Proofview.tactic -> 'a t |
| 34 | (** Transform a tactic into a focussing tactic. The resulting tactic is not |
| 35 | focused. *) |
| 36 | |
| 37 | val run : 'a t -> ('a -> unit Proofview.tactic) -> unit Proofview.tactic |
| 38 | (** Given a continuation producing a tactic, evaluates the focussing tactic. If |
| 39 | the tactic has not focused, then the continuation is evaluated once. |
| 40 | Otherwise it is called in each of the currently focused goals. *) |
| 41 | |
| 42 | (** {5 Focussing} *) |
| 43 | |
| 44 | (** Enter a goal. The resulting tactic is focused. *) |
| 45 | |
| 46 | val enter : (Proofview.Goal.t -> 'a t) -> 'a t |
| 47 | (** Enter a goal, without evar normalization. The resulting tactic is |
| 48 | focused. *) |
| 49 | |
| 50 | val with_env : 'a t -> (Environ.env*'a) t |
| 51 | (** [with_env t] returns, in addition to the return type of [t], an |
| 52 | environment, which is the global environment if [t] does not focus on |
| 53 | goals, or the local goal environment if [t] focuses on goals. *) |
| 54 | |
| 55 | (** {5 Notations} *) |
| 56 | |
| 57 | val (>>=) : 'a t -> ('a -> 'b t) -> 'b t |
| 58 | (** Notation for {!bind}. *) |
| 59 | |
| 60 | val (<*>) : unit t -> 'a t -> 'a t |
| 61 | (** Sequence. *) |
| 62 | |
| 63 | (** {5 List operations} *) |
| 64 | |
| 65 | module List : Monad.ListS with type 'a t := 'a t |
| 66 | |
| 67 | (** {5 Notations} *) |
| 68 | |
| 69 | module Notations : |
| 70 | sig |
| 71 | val (>>=) : 'a t -> ('a -> 'b t) -> 'b t |
| 72 | val (<*>) : unit t -> 'a t -> 'a t |
| 73 | end |