NOTE: effect type system
This note will not be very complete, but might become a series.
1. Effect as interface
The first case, use maybe to implement raise effect.
fun raise-maybe( action : () -> <raise|e> a ) : e maybe<a>
with handler
return(x) Just(x) // normal return: wrap in Just
ctl raise(msg) Nothing // exception: return Nothing directly
action()
<raise|e>ensure it's able to handle the effect other thanraisemaybebecame the underlying implementation of effectraisereturn(x)lift thex : ainto this monoidctlshould be something likeabortin delimited continuation, but the type is ensured, rather than depends on context
2. Polymorphic effect
fun map : (xs : list<a>, f : (a) -> e b) -> e list<b>
match xs
Cons(x,xx) -> Cons( f(x), map(xx,f) )
Nil -> Nil
3. Current question
How about
fun foo() : <state<int>,state<int>,state<int>> int
- How to implement concurrency