Closed dannypsnl closed 2 weeks ago
(define/eff (f [msg : String]) : Void { log }
(log msg))
(: emap : (All (I)
(-> (-> String (-> I Void))
(Listof String)
(-> I Void))))
(define (emap f l)
(λ (eff)
(map (λ ([x : String]) ((f x) eff))
l)
(void)))
(with-eff/handlers ([log (λ ([resume : (-> Void Void)]
[msg : String])
(printf "~a~n" msg)
(resume (void)))])
(emap f '("hi" "ho" "ha")))
This one success, output
hi
ho
ha
An effect type must be provided, e.g.
This equation defines the type
Eff
, but we cannot simply usedefine-type
because need to lookupeffect log
to know the signature ofObject
; so alternative I thought a macrocan be useful, then type of
map
can use polymorphism of typed/racket, belike: