mirror of
https://github.com/unisonweb/unison.git
synced 2024-11-04 01:03:36 +03:00
30 lines
597 B
Plaintext
30 lines
597 B
Plaintext
--State3 ability
|
|
structural ability State se2 where
|
|
put : ∀ se . se -> {State se} ()
|
|
get : ∀ se . () -> {State se} se
|
|
|
|
state : ∀ s a . s -> Request (State s) a -> (s, a)
|
|
state woot = cases
|
|
{ State.get () -> k } -> handle k woot with state woot
|
|
{ State.put snew -> k } -> handle k () with state snew
|
|
|
|
ex1 : (Nat, Nat)
|
|
ex1 = handle State.get () with state 42
|
|
|
|
ex1a : (Nat, Nat)
|
|
ex1a = handle 49 with state 42
|
|
|
|
ex1b = handle 0 with x -> 10
|
|
|
|
ex1c : Nat
|
|
ex1c = handle 0 with x -> 10
|
|
|
|
ex1d = handle 49 with state 42
|
|
|
|
ex2 = handle State.get () with state 42
|
|
|
|
ex3 : (Nat, Nat)
|
|
ex3 = ex2
|
|
|
|
()
|