From f4faaed464d2d0bd61fb0f0b098c0f084aac5493 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 23 Oct 2018 09:31:11 -0400 Subject: [PATCH] Define upcasting on Eff. --- src/Analysis/Abstract/Graph.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Analysis/Abstract/Graph.hs b/src/Analysis/Abstract/Graph.hs index de95c331c..bc67fb68c 100644 --- a/src/Analysis/Abstract/Graph.hs +++ b/src/Analysis/Abstract/Graph.hs @@ -160,6 +160,9 @@ eavesdrop :: (HFunctor eff, Carrier sig m, Member eff sig, Applicative m) -> m a eavesdrop m f = runEavesdropC f (interpret m) +upcast :: Eff m a -> Eff (EavesdropC eff (Eff m)) a +upcast m = Eff (\ k -> EavesdropC (\ f -> m >>= runEavesdropC f . k)) + newtype EavesdropC eff m a = EavesdropC ((forall x . eff m (m x) -> m ()) -> m a) runEavesdropC :: (forall x . eff m (m x) -> m ()) -> EavesdropC eff m a -> m a