Library zoo_saturn.stack_mpmc_2__code
Require Import zoo.prelude.
Require Import zoo.language.typeclasses.
Require Import zoo.language.notations.
Require Import zoo_std.clist.
Require Import zoo_std.domain.
Require Import zoo_std.optional.
Require Import zoo.options.
Definition stack_mpmc_2ู create : val :=
๐ณ๐๐ป โฝ โ
๐ฟ๐ฒ๐ณ ยงclistู Open.
Definition stack_mpmc_2ู push : val :=
๐ฟ๐ฒ๐ฐ "push" "t" "v" โ
๐บ๐ฎ๐๐ฐ๐ต !"t" ๐๐ถ๐๐ต
| clistู Closed โ
true
| โฝ ๐ฎ๐ "old" โ
๐น๐ฒ๐ "new_" = โclistู Cons[ "v", "old" ] ๐ถ๐ป
๐ถ๐ณ ๐ฐ๐ฎ๐ "t".[contents] "old" "new_" ๐๐ต๐ฒ๐ป (
false
) ๐ฒ๐น๐๐ฒ (
domainู yield () โฎ
"push" "t" "v"
)
๐ฒ๐ป๐ฑ.
Definition stack_mpmc_2ู pop : val :=
๐ฟ๐ฒ๐ฐ "pop" "t" โ
๐บ๐ฎ๐๐ฐ๐ต !"t" ๐๐ถ๐๐ต
| clistู Closed โ
ยงoptionalู Anything
| clistู Open โ
ยงoptionalู Nothing
| clistู Cons "v" "new_" ๐ฎ๐ "old" โ
๐ถ๐ณ ๐ฐ๐ฎ๐ "t".[contents] "old" "new_" ๐๐ต๐ฒ๐ป (
โoptionalู Something( "v" )
) ๐ฒ๐น๐๐ฒ (
domainู yield () โฎ
"pop" "t"
)
๐ฒ๐ป๐ฑ.
Definition stack_mpmc_2ู is_closed : val :=
๐ณ๐๐ป "t" โ
!"t" == ยงclistู Closed.
Definition stack_mpmc_2ู close : val :=
๐ณ๐๐ป "t" โ
๐ ๐ฐ๐ต๐ด "t".[contents] ยงclistู Closed.
Require Import zoo.language.typeclasses.
Require Import zoo.language.notations.
Require Import zoo_std.clist.
Require Import zoo_std.domain.
Require Import zoo_std.optional.
Require Import zoo.options.
Definition stack_mpmc_2ู create : val :=
๐ณ๐๐ป โฝ โ
๐ฟ๐ฒ๐ณ ยงclistู Open.
Definition stack_mpmc_2ู push : val :=
๐ฟ๐ฒ๐ฐ "push" "t" "v" โ
๐บ๐ฎ๐๐ฐ๐ต !"t" ๐๐ถ๐๐ต
| clistู Closed โ
true
| โฝ ๐ฎ๐ "old" โ
๐น๐ฒ๐ "new_" = โclistู Cons[ "v", "old" ] ๐ถ๐ป
๐ถ๐ณ ๐ฐ๐ฎ๐ "t".[contents] "old" "new_" ๐๐ต๐ฒ๐ป (
false
) ๐ฒ๐น๐๐ฒ (
domainู yield () โฎ
"push" "t" "v"
)
๐ฒ๐ป๐ฑ.
Definition stack_mpmc_2ู pop : val :=
๐ฟ๐ฒ๐ฐ "pop" "t" โ
๐บ๐ฎ๐๐ฐ๐ต !"t" ๐๐ถ๐๐ต
| clistู Closed โ
ยงoptionalู Anything
| clistู Open โ
ยงoptionalู Nothing
| clistู Cons "v" "new_" ๐ฎ๐ "old" โ
๐ถ๐ณ ๐ฐ๐ฎ๐ "t".[contents] "old" "new_" ๐๐ต๐ฒ๐ป (
โoptionalู Something( "v" )
) ๐ฒ๐น๐๐ฒ (
domainู yield () โฎ
"pop" "t"
)
๐ฒ๐ป๐ฑ.
Definition stack_mpmc_2ู is_closed : val :=
๐ณ๐๐ป "t" โ
!"t" == ยงclistู Closed.
Definition stack_mpmc_2ู close : val :=
๐ณ๐๐ป "t" โ
๐ ๐ฐ๐ต๐ด "t".[contents] ยงclistู Closed.