Library MonadVM.Option
File generated by rocq-of-ocaml
Require Import RocqOfOCaml.RocqOfOCaml.
Require Import RocqOfOCaml.Settings.
Require Import MonadVM.Support.Variants.
Require MonadVM.Support.CryptoBlake2.
Require Import RocqOfOCaml.Opaque.
Local Ltac _rocq_witness_type typ :=
let typ := eval hnf in typ in
lazymatch typ with
| list ?a ⇒ let a := _rocq_witness_type a in constr:(list a)
| option ?a ⇒ let a := _rocq_witness_type a in constr:(option a)
| prod ?a ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(prod a b)
| sum ?a ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(sum a b)
| ?a → ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(a → b)
| _ ⇒ typ
end.
Definition t (a : Set) := RocqOfOCaml.OCamlOption.t a.
Definition none {a : Set} : option a := RocqOfOCaml.OCamlOption.none.
Definition some {a : Set} : a → option a := RocqOfOCaml.OCamlOption.some.
Definition value {a : Set} : option a → a → a :=
RocqOfOCaml.OCamlOption.value.
Definition get {a : Set}
(_rocq_fallback_arg_0 :
ltac:(let typ := constr:(ltac:(first [unshelve refine ((a)%type
)]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ))
: option a → a :=
(RocqOfOCaml.OCamlOption.get (H := RocqOfOCaml.Opaque.legacy_witness
_rocq_fallback_arg_0)).
Definition bind {a b : Set} : option a → (a → option b) → option b :=
RocqOfOCaml.OCamlOption.bind.
Definition join {a : Set} : option (option a) → option a :=
RocqOfOCaml.OCamlOption.join.
Definition map {a b : Set} : (a → b) → option a → option b :=
RocqOfOCaml.OCamlOption.map.
Definition product {a b : Set} : option a → option b → option (a × b) :=
RocqOfOCaml.OCamlOption.product.
Definition fold {a b : Set} : a → (b → a) → option b → a :=
RocqOfOCaml.OCamlOption.fold.
Definition iter {a : Set} : (a → unit) → option a → unit :=
RocqOfOCaml.OCamlOption.iter.
Definition blend {a : Set} : (a → a → a) → option a → option a → option a
:= RocqOfOCaml.OCamlOption.blend.
Definition for_all {a : Set} : (a → bool) → option a → bool :=
RocqOfOCaml.OCamlOption.for_all.
Definition _exists {a : Set} : (a → bool) → option a → bool :=
RocqOfOCaml.OCamlOption._exists.
Definition is_none {a : Set} : option a → bool :=
RocqOfOCaml.OCamlOption.is_none.
Definition is_some {a : Set} : option a → bool :=
RocqOfOCaml.OCamlOption.is_some.
Definition equal {a : Set} : (a → a → bool) → option a → option a → bool :=
RocqOfOCaml.OCamlOption.equal.
Definition compare {a : Set} : (a → a → int) → option a → option a → int :=
RocqOfOCaml.OCamlOption.compare.
Definition to_result {e a : Set} : e → option a → sum a e :=
RocqOfOCaml.OCamlOption.to_result.
Definition to_list {a : Set} : option a → list a :=
RocqOfOCaml.OCamlOption.to_list.
Definition to_seq {a : Set} : option a → RocqOfOCaml.OCamlSeq.t a :=
RocqOfOCaml.OCamlOption.to_seq.
Module Syntax := RocqOfOCaml.OCamlOption.Syntax.
Definition get_or_create {a : Set} (create : unit → a) : Lens.t (option a) a :=
{|
Lens.t.get :=
fun (function_parameter : option a) ⇒
match function_parameter with
| None ⇒ create tt
| Some v_value ⇒ v_value
end;
Lens.t.set :=
fun (x_value : a) ⇒
fun (function_parameter : RocqOfOCaml.OCamlOption.t a) ⇒
let '_ := function_parameter in
Some x_value; |}.
Definition get_or_default {a : Set} (default : a) : Lens.t (option a) a :=
{|
Lens.t.get :=
fun (function_parameter : option a) ⇒
match function_parameter with
| None ⇒ default
| Some v_value ⇒ v_value
end;
Lens.t.set :=
fun (x_value : a) ⇒
fun (function_parameter : RocqOfOCaml.OCamlOption.t a) ⇒
let '_ := function_parameter in
Some x_value; |}.
Definition get_or_throw {a : Set}
(_rocq_fallback_arg_0 :
ltac:(unshelve refine ((a)%type); RocqOfOCaml.Opaque.opaque_inhabit 64%nat)) : Lens.t
(option a) a :=
{| Lens.t.get := (get (_rocq_fallback_arg_0));
Lens.t.set :=
fun (x_value : a) ⇒
fun (function_parameter : RocqOfOCaml.OCamlOption.t a) ⇒
let '_ := function_parameter in
Some x_value; |}.
Definition op_gtgteq {A B : Set} : option A → (A → option B) → option B :=
bind.
Definition op_letdollar {A B : Set} : option A → (A → option B) → option B :=
bind.
Definition _return {A : Set} (x_value : A) : RocqOfOCaml.OCamlOption.t A :=
Some x_value.
Definition ensure (predicate : bool) : option unit :=
if predicate then
Some tt
else
None.
Require Import RocqOfOCaml.Settings.
Require Import MonadVM.Support.Variants.
Require MonadVM.Support.CryptoBlake2.
Require Import RocqOfOCaml.Opaque.
Local Ltac _rocq_witness_type typ :=
let typ := eval hnf in typ in
lazymatch typ with
| list ?a ⇒ let a := _rocq_witness_type a in constr:(list a)
| option ?a ⇒ let a := _rocq_witness_type a in constr:(option a)
| prod ?a ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(prod a b)
| sum ?a ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(sum a b)
| ?a → ?b ⇒ let a := _rocq_witness_type a in
let b := _rocq_witness_type b in constr:(a → b)
| _ ⇒ typ
end.
Definition t (a : Set) := RocqOfOCaml.OCamlOption.t a.
Definition none {a : Set} : option a := RocqOfOCaml.OCamlOption.none.
Definition some {a : Set} : a → option a := RocqOfOCaml.OCamlOption.some.
Definition value {a : Set} : option a → a → a :=
RocqOfOCaml.OCamlOption.value.
Definition get {a : Set}
(_rocq_fallback_arg_0 :
ltac:(let typ := constr:(ltac:(first [unshelve refine ((a)%type
)]; first [match goal with |- ?g ⇒ let sort := type of g in lazymatch sort with Set ⇒ fail | _ ⇒ shelve end end | eassumption | typeclasses eauto | RocqOfOCaml.Opaque.opaque_inhabit 64%nat])) in let typ := _rocq_witness_type typ in exact typ))
: option a → a :=
(RocqOfOCaml.OCamlOption.get (H := RocqOfOCaml.Opaque.legacy_witness
_rocq_fallback_arg_0)).
Definition bind {a b : Set} : option a → (a → option b) → option b :=
RocqOfOCaml.OCamlOption.bind.
Definition join {a : Set} : option (option a) → option a :=
RocqOfOCaml.OCamlOption.join.
Definition map {a b : Set} : (a → b) → option a → option b :=
RocqOfOCaml.OCamlOption.map.
Definition product {a b : Set} : option a → option b → option (a × b) :=
RocqOfOCaml.OCamlOption.product.
Definition fold {a b : Set} : a → (b → a) → option b → a :=
RocqOfOCaml.OCamlOption.fold.
Definition iter {a : Set} : (a → unit) → option a → unit :=
RocqOfOCaml.OCamlOption.iter.
Definition blend {a : Set} : (a → a → a) → option a → option a → option a
:= RocqOfOCaml.OCamlOption.blend.
Definition for_all {a : Set} : (a → bool) → option a → bool :=
RocqOfOCaml.OCamlOption.for_all.
Definition _exists {a : Set} : (a → bool) → option a → bool :=
RocqOfOCaml.OCamlOption._exists.
Definition is_none {a : Set} : option a → bool :=
RocqOfOCaml.OCamlOption.is_none.
Definition is_some {a : Set} : option a → bool :=
RocqOfOCaml.OCamlOption.is_some.
Definition equal {a : Set} : (a → a → bool) → option a → option a → bool :=
RocqOfOCaml.OCamlOption.equal.
Definition compare {a : Set} : (a → a → int) → option a → option a → int :=
RocqOfOCaml.OCamlOption.compare.
Definition to_result {e a : Set} : e → option a → sum a e :=
RocqOfOCaml.OCamlOption.to_result.
Definition to_list {a : Set} : option a → list a :=
RocqOfOCaml.OCamlOption.to_list.
Definition to_seq {a : Set} : option a → RocqOfOCaml.OCamlSeq.t a :=
RocqOfOCaml.OCamlOption.to_seq.
Module Syntax := RocqOfOCaml.OCamlOption.Syntax.
Definition get_or_create {a : Set} (create : unit → a) : Lens.t (option a) a :=
{|
Lens.t.get :=
fun (function_parameter : option a) ⇒
match function_parameter with
| None ⇒ create tt
| Some v_value ⇒ v_value
end;
Lens.t.set :=
fun (x_value : a) ⇒
fun (function_parameter : RocqOfOCaml.OCamlOption.t a) ⇒
let '_ := function_parameter in
Some x_value; |}.
Definition get_or_default {a : Set} (default : a) : Lens.t (option a) a :=
{|
Lens.t.get :=
fun (function_parameter : option a) ⇒
match function_parameter with
| None ⇒ default
| Some v_value ⇒ v_value
end;
Lens.t.set :=
fun (x_value : a) ⇒
fun (function_parameter : RocqOfOCaml.OCamlOption.t a) ⇒
let '_ := function_parameter in
Some x_value; |}.
Definition get_or_throw {a : Set}
(_rocq_fallback_arg_0 :
ltac:(unshelve refine ((a)%type); RocqOfOCaml.Opaque.opaque_inhabit 64%nat)) : Lens.t
(option a) a :=
{| Lens.t.get := (get (_rocq_fallback_arg_0));
Lens.t.set :=
fun (x_value : a) ⇒
fun (function_parameter : RocqOfOCaml.OCamlOption.t a) ⇒
let '_ := function_parameter in
Some x_value; |}.
Definition op_gtgteq {A B : Set} : option A → (A → option B) → option B :=
bind.
Definition op_letdollar {A B : Set} : option A → (A → option B) → option B :=
bind.
Definition _return {A : Set} (x_value : A) : RocqOfOCaml.OCamlOption.t A :=
Some x_value.
Definition ensure (predicate : bool) : option unit :=
if predicate then
Some tt
else
None.