mirror of
https://github.com/unisonweb/unison.git
synced 2024-10-26 11:07:48 +03:00
8cee89dc29
- () -> Unit - ().() -> Unit.Unit - Pair -> Tuple - Pair.Pair -> Tuple.Cons - Sequence -> List - Effect -> Request - {Int,Nat,Float,Text}.{==,<,<=,>,>=} -> {Int,Nat,Float,Text}.{eq,lt,lteq,gt,gteq} - mark Text.!= as a deprecated builtin
23 lines
720 B
Plaintext
23 lines
720 B
Plaintext
--handle inference
|
|
ability State s where
|
|
get : ∀ s . () -> {State s} s
|
|
set : ∀ s . s -> {State s} ()
|
|
state : ∀ a s . s -> Request (State s) a -> a
|
|
state s e = case e of
|
|
{a} -> a
|
|
{State.get _ -> k} -> handle state s in k s
|
|
{State.set s -> k} -> handle state s in k ()
|
|
-- modify : ∀ s . (s -> s) -> {State s} ()
|
|
-- modify f = State.set (f (State.get()))
|
|
ex : () -> {State Nat} Nat
|
|
ex blah =
|
|
State.get() Nat.+ 42
|
|
-- note this currently succeeds, the handle block
|
|
-- gets an inferred type of ∀ a . a, it appears that
|
|
-- the existential `a` which gets instantiated for the
|
|
-- state call never gets refined, most likely due to
|
|
-- missing a subtype check in handle
|
|
y : Text
|
|
y = handle state 5 in ex ()
|
|
()
|