(************************************************************************) (* * The Rocq Prover / The Rocq Development Team *) (* v * Copyright INRIA, CNRS and contributors *) (* <O___,, * (see version control and CREDITS file for authors & dates) *) (* \VV/ **************************************************************) (* // * This file is distributed under the terms of the *) (* * GNU Lesser General Public License Version 2.1 *) (* * (see LICENSE file for the text of the license) *) (************************************************************************)
(** This file implements the low-level monadic operations used by the tacticmonad.Themonadisdividedintotwolayers:anon-logical layerwhichconsistsinoperationswhichwillnot(orcannot)be backtrackedincaseoffailure(input/outputorpersistentstate) andalogicallayerwhichhandlesbacktracking,proof
manipulation, and any other effect which needs to backtrack. *)
(** {6 Exceptions} *)
(** To help distinguish between exceptions raised by the IO monad from theoneusednativelybyRocq,theformerarewrappedin [Exception].Itisonlyusedinternallysothat[catch]blocksof theIOmonadwouldonlycatchexceptionsraisedbythe[raise] functionoftheIOmonad,andnotforinstance,bysystem interrupts.Alsousedin[Proofview]toavoidcapturingexception fromtheIOmonad([Proofview]catcheserrorsinitscompatibility
layer, and when lifting goal-level expressions). *)
exception Exception of exn
(** This exception is used to signal abortion in [timeout] functions. *)
exception Tac_Timeout
(** This exception is used by the tactics to signal failure by lack of successes,ratherthansomeotherexceptions(likesystem
interrupts). *)
exception TacticFailure of exn
(** {6 Non-logical layer} *)
(** The non-logical monad is a simple [unit -> 'a] (i/o) monad. The operationsaresimplewrappersaroundcorrespondingusual
operations and require little documentation. *)
module NonLogical : sig
include Monad.S
val ignore : 'a t -> unit t
type'a ref
valref : 'a -> 'a ref t (** [Pervasives.(:=)] *)
val (:=) : 'a ref -> 'a -> unit t (** [Pervasives.(!)] *)
val (!) : 'a ref -> 'a t
val read_line : string t val print_char : char -> unit t
(** Loggers. The buffer is also flushed. *) val print_debug : Pp.t -> unit t val print_warning : Pp.t -> unit t val print_notice : Pp.t -> unit t val print_info : Pp.t -> unit t
(** [Pervasives.raise]. Except that exceptions are wrapped with
{!Exception}. *) valraise : Exninfo.iexn -> 'a t
(** [try ... with ...] but restricted to {!Exception}. *) val catch : 'a t -> (Exninfo.iexn -> 'a t) -> 'a t val timeout : float -> 'a t -> 'a option t
(** Construct a monadified side-effect. Exceptions raised by the argument are
wrapped with {!Exception}. *) val make : (unit -> 'a) -> 'a t
(** [run] performs effects. *) val run : 'a t -> 'a
end
(** {6 Logical layer} *)
(** The logical monad is a backtracking monad on top of which is layeredastatemonad(whichisusedtoimplementallofread/write, readonly,andwriteonlyeffects).Thestatemonadbeinglayeredon topofthebacktrackingmonadmakesitsothatthestateis backtrackedonfailure.
(** A view type for the logical monad, which is a form of list, hence
we can decompose it with as a list. *) type ('a, 'b, 'e) list_view_ =
| Nil of'e
| Cons of'a * 'b
type ('a, 'b, 'e) list_view = ('a, 'e -> 'b, 'e) list_view_
module BackState : sig
type (+'a, -'i, +'o, 'e) t val return : 'a -> ('a, 's, 's, 'e) t val (>>=) : ('a, 'i, 'm, 'e) t -> ('a -> ('b, 'm, 'o, 'e) t) -> ('b, 'i, 'o, 'e) t val (>>) : (unit, 'i, 'm, 'e) t -> ('b, 'm, 'o, 'e) t -> ('b, 'i, 'o, 'e) t valmap : ('a -> 'b) -> ('a, 'i, 'o, 'e) t -> ('b, 'i, 'o, 'e) t
val ignore : ('a, 'i, 'o, 'e) t -> (unit, 'i, 'o, 'e) t
valset : 'o -> (unit, 'i, 'o, 'e) t val get : ('s, 's, 's, 'e) t val modify : ('i -> 'o) -> (unit, 'i, 'o, 'e) t
val interleave : ('e1 -> 'e2) -> ('e2 -> 'e1) -> ('a, 'i, 'o, 'e1) t ->
('a, 'i, 'o, 'e2) t (** [interleave src dst m] adapts the exceptional content of the monad accordingtothefunctions[src]and[dst].Toensureameaningfulresult, thosefunctionsmustformaretraction,i.e.[dst(srce1)=e1]forall
[e1]. This is typically the case when the type ['e1] is [unit]. *)
val zero : 'e -> ('a, 'i, 'o, 'e) t val plus : ('a, 'i, 'o, 'e) t -> ('e -> ('a, 'i, 'o, 'e) t) -> ('a, 'i, 'o, 'e) t
val split : ('a, 's, 's, 'e) t ->
(('a, ('a, 'i, 's, 'e) t, 'e) list_view, 's, 's, 'e) t
val once : ('a, 'i, 'o, 'e) t -> ('a, 'i, 'o, 'e) t val break : ('e -> 'e option) -> ('a, 'i, 'o, 'e) t -> ('a, 'i, 'o, 'e) t val lift : 'a NonLogical.t -> ('a, 's, 's, 'e) t
val run : ('a, 'i, 'o, 'e) t -> 'i -> ('a * 'o, 'e) reified
end
(** The monad is parametrised in the types of state, environment and
writer. *)
module type Param = sig
(** Read only *) type e
(** Write only *) type w
(** [w] must be a monoid *) val wunit : w val wprod : w -> w -> w
(** Read-write *) type s
(** Update-only. Essentially a writer on [u->u]. *) type u
(** [u] must be pointed. *) val uunit : u
end
module Logical (P:Param) : sig
include Monad.S
val ignore : 'a t -> unit t
valset : P.s -> unit t val get : P.s t val modify : (P.s -> P.s) -> unit t val put : P.w -> unit t val current : P.e t val local : P.e -> 'a t -> 'a t val update : (P.u -> P.u) -> unit t
val zero : Exninfo.iexn -> 'a t val plus : 'a t -> (Exninfo.iexn -> 'a t) -> 'a t val split : 'a t -> ('a, 'a t, Exninfo.iexn) list_view t val once : 'a t -> 'a t val break : (Exninfo.iexn -> Exninfo.iexn option) -> 'a t -> 'a t
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.