dannypsnl
The project integrates an effect system into typed/racket.
(f))
Type Checker: type mismatch; object lacks expected method ‘log’ in: (with-eff/handlers ((raise (λ ((resume : (-> Void Void)) (err : String)) : Void (printf "got error: ~a~n" err)))) (f))
(f)))
The function g handle the log effect, and let f use it’s raise .
The higher-order effect can be done by use Eff type and the effect object, then passing current effect object eff to the invoked function, but the API is still sharp, it’s easy to forget the pattern (λ (args... )((fargs... )eff)).
(number-to-stringx))(emapf
syntax
( effect name:type)
syntax
( effect-out name)
syntax
( Eff T(effs...))
syntax
( effs ...)
Produce an Object where each method with an effect signature, this is the effect object type.
syntax
( define/eff (name[param:T]...):T_out{e*...}body*...body)
syntax
( with-eff :T_out{e*...}body*...body)
This macro also bind a list of function to wrap eff object, e.g.so you can invoke effect just like usual function.
syntax
( with-eff/handlers (handlers...)body)
(f))
To generate proper call/prompt and abort/cc, every effect handler can only take one input type, so if you want to transfer several arguments, use structure to wrap them.