Closed myuon closed 7 years ago
Is peelEff1
what you want?
data GetPut s a where
Get :: GetPut s s
Put :: s -> GetPut s ()
runGetPut :: Eff ((k >: GetPut s) ': r) a -> s -> Eff r (a, s)
runGetPut = peelEff1 (\a s -> return (a, s))
$ \t k s -> case t of
Get -> k s s
Put s' -> k () s'
Oh, Great! I just didn't understand how peelEff
works.
Thanks :smiley:
I want to implement an effect handler, using operation pattern-matching with continuations. For example, here is a simple state example:
In this example, type of the two continuation
k
in case pattern should bea -> Eff [State a] r
and() -> Eff [State a] r
.However,
peelEff
has typeRebinder xs r -> (a -> r) -> (forall x. t x -> (x -> r) -> r) -> Eff ((k >: t) ': xs) a -> r
, this seems not fit in this example. The type of operation handling function should beforall x. t x -> (x -> Eff xs r) -> r
.So how to implement this effect handler in extensible?