@@ -3,14 +3,8 @@ module Effectful.Handler
5 -- * Handling effects
5 -- * Handling effects
8 , interpret
6 , interpret
11− -- ** Derived handlers
12 , reinterpret
7 , reinterpret
15 -- ** Handling local 'Eff' operations
9 -- ** Handling local 'Eff' operations
16 , LocalEnv
10 , LocalEnv
@@ -81,57 +75,34 @@ send op = unsafeEff $ \es -> do
81----------------------------------------
75----------------------------------------
82-- Interpretation
76-- Interpretation
84−-- | Interpret a first order effect.
78+-- | Interpret an effect.
86− :: (forall r m. HasCallStack => e m r -> Eff es r)
87− -- ^ The effect handler.
90−interpret handler m = unsafeEff $ \es -> do
92− runHandler es (Handler les $ \_ -> handler) m
94−-- | Interpret a higher order effect.
96-- /Note:/ 'LocalEnv' is for handling local 'Eff' operations using a function
80-- /Note:/ 'LocalEnv' is for handling local 'Eff' operations using a function
97-- from the 'localUnlift' family.
81-- from the 'localUnlift' family.
98−interpretM
82+interpret
99 :: (forall r localEs. HasCallStack => LocalEnv localEs -> e (Eff localEs) r -> Eff es r)
83 :: (forall r localEs. HasCallStack => LocalEnv localEs -> e (Eff localEs) r -> Eff es r)
100 -- ^ The effect handler.
84 -- ^ The effect handler.
101 -> Eff (e : es) a
85 -> Eff (e : es) a
102 -> Eff es a
86 -> Eff es a
103−interpretM handler m = unsafeEff $ \es -> do
87+interpret handler m = unsafeEff $ \es -> do
104 les <- forkEnv es
88 les <- forkEnv es
105 runHandler es (Handler les handler) m
89 runHandler es (Handler les handler) m
107----------------------------------------
91----------------------------------------
108-- Reinterpretation
92-- Reinterpretation
110−-- | Interpret a first order effect using other effects.
112− :: (Eff handlerEs a -> Eff es b)
113− -- ^ Introduction of effects encapsulated within the handler.
114− -> (forall r m. HasCallStack => e m r -> Eff handlerEs r)
115− -- ^ The effect handler.
118−reinterpret runHandlerEs handler m = unsafeEff $ \es -> do
120− (`unEff` les0) . runHandlerEs . unsafeEff $ \les -> do
121− runHandler es (Handler les $ \_ -> handler) m
123−-- | Interpret a higher order effect using other effects.
94+-- | Interpret an effect using other effects.
125-- /Note:/ 'LocalEnv' is for handling local 'Eff' operations using a function
96-- /Note:/ 'LocalEnv' is for handling local 'Eff' operations using a function
126-- from the 'localUnlift' family.
97-- from the 'localUnlift' family.
127−reinterpretM
98+reinterpret
128 :: (Eff handlerEs a -> Eff es b)
99 :: (Eff handlerEs a -> Eff es b)
129 -- ^ Introduction of effects encapsulated within the handler.
100 -- ^ Introduction of effects encapsulated within the handler.
130 -> (forall r localEs. HasCallStack => LocalEnv localEs -> e (Eff localEs) r -> Eff handlerEs r)
101 -> (forall r localEs. HasCallStack => LocalEnv localEs -> e (Eff localEs) r -> Eff handlerEs r)
131 -- ^ The effect handler.
102 -- ^ The effect handler.
132 -> Eff (e : es) a
103 -> Eff (e : es) a
133 -> Eff es b
104 -> Eff es b
134−reinterpretM runHandlerEs handler m = unsafeEff $ \es -> do
105+reinterpret runHandlerEs handler m = unsafeEff $ \es -> do
135 les0 <- forkEnv es
106 les0 <- forkEnv es
136 (`unEff` les0) . runHandlerEs . unsafeEff $ \les -> do
107 (`unEff` les0) . runHandlerEs . unsafeEff $ \les -> do
137 runHandler es (Handler les handler) m
108 runHandler es (Handler les handler) m