From 7c1c7437e9b04cb930a52df54f98fdcae4c202f0 Mon Sep 17 00:00:00 2001 From: Peter Trsko Date: Mon, 30 Jan 2017 16:24:45 +0100 Subject: [PATCH] Relaxed type signature of asks function It's previous type signature: asks :: (e -> a) -> Eff '[Reader e] a Was very restrictive, therefore, its usage was limited to very few effect stacks. New type signature: asks :: Member (Reader e) effs => (e -> a) -> Eff effs a Is much more liberal, and allows us to use `asks` in all the places we would have to use something like `f <$> ask`. Resolves #7 --- src/Control/Monad/Freer/Reader.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Control/Monad/Freer/Reader.hs b/src/Control/Monad/Freer/Reader.hs index f40a1c5..96dae19 100644 --- a/src/Control/Monad/Freer/Reader.hs +++ b/src/Control/Monad/Freer/Reader.hs @@ -63,16 +63,16 @@ ask = send Reader -- | Request a value of the environment, and apply as selector\/projection -- function to it. asks - :: (e -> a) + :: Member (Reader e) effs + => (e -> a) -- ^ The selector\/projection function to be applied to the environment. - -> Eff '[Reader e] a + -> Eff effs a asks f = f <$> ask -- | Handler for 'Reader' effects. runReader :: Eff (Reader e ': effs) a -> e -> Eff effs a runReader m e = handleRelay pure (\Reader k -> k e) m - -- | Locally rebind the value in the dynamic environment. -- -- This function is like a relay; it is both an admin for 'Reader' requests,