on master help sign in
Rename type variables used in the interpret family
c146d22Andrzej Rybczak
src/Effectful/Internal/Monad.hs+1−1
@@ -71,7 +71,7 @@ type role Eff nominal representational
71-- @
71-- @
72--
72--
73-- Normally, a concrete list of effects is not used to parameterize 'Eff'.
73-- Normally, a concrete list of effects is not used to parameterize 'Eff'.
74−-- Instead, the '(:>)' class is used to express constraints on the list of
74+-- Instead, the '(:>)' type class is used to express constraints on the list of
75-- effects without coupling an operation to a concrete list of effects. For
75-- effects without coupling an operation to a concrete list of effects. For
76-- example, the above example would more commonly be expressed with the
76-- example, the above example would more commonly be expressed with the
77-- following type:
77-- following type:
src/Effectful/Interpreter.hs+44−44
@@ -26,12 +26,12 @@ import Effectful.Internal.Monad
26----------------------------------------
26----------------------------------------
27-- Interpreter
27-- Interpreter
28
28
29−data Interpreter (e :: Effect) = forall localEs. Interpreter
29+data Interpreter (e :: Effect) = forall handlerEs. Interpreter
30− { _env :: Env localEs
30+ { _env :: Env handlerEs
31− , _interpret :: forall a es. HasCallStack
31+ , _interpret :: forall a localEs. HasCallStack
32− => RunIn es IO
32+ => RunIn localEs IO
33− -> e (Eff es) a
33+ -> e (Eff localEs) a
34− -> Eff localEs a
34+ -> Eff handlerEs a
35 }
35 }
36
36
37runInterpreter :: Env es -> Interpreter e -> Eff (e : es) a -> IO a
37runInterpreter :: Env es -> Interpreter e -> Eff (e : es) a -> IO a
@@ -62,32 +62,32 @@ send op = readerEffectM $ \Interpreter{..} -> do
62
62
63-- | Interpret a first order effect.
63-- | Interpret a first order effect.
64interpret
64interpret
65− :: (forall r es. HasCallStack => e (Eff es) r -> Eff baseEs r)
65+ :: (forall r localEs. HasCallStack => e (Eff localEs) r -> Eff es r)
66− -- ^ The effect handler
66+ -- ^ The effect handler.
67− -> Eff (e : baseEs) a
67+ -> Eff (e : es) a
68− -> Eff baseEs a
68+ -> Eff es a
69interpret interpreter m = unsafeEff $ \es -> do
69interpret interpreter m = unsafeEff $ \es -> do
70 les <- forkEnv es
70 les <- forkEnv es
71 runInterpreter es (Interpreter les $ \_ -> interpreter) m
71 runInterpreter es (Interpreter les $ \_ -> interpreter) m
72
72
73−-- | Interpret a higher order effect with help of a function running 'Eff'
73+-- | Interpret a higher order effect with help of a function running local 'Eff'
74−-- operations in the local 'Eff' of an effect handler.
74+-- operations in the context of an effect handler.
75interpretM
75interpretM
76− :: (forall r es. HasCallStack => RunIn es (Eff baseEs) -> e (Eff es) r -> Eff baseEs r)
76+ :: (forall r localEs. HasCallStack => RunIn localEs (Eff es) -> e (Eff localEs) r -> Eff es r)
77− -- ^ The effect handler
77+ -- ^ The effect handler.
78− -> Eff (e : baseEs) a
78+ -> Eff (e : es) a
79− -> Eff baseEs a
79+ -> Eff es a
80interpretM interpreter m = unsafeEff $ \es -> do
80interpretM interpreter m = unsafeEff $ \es -> do
81 les <- forkEnv es
81 les <- forkEnv es
82 runInterpreter es (Interpreter les $ \k -> interpreter $ unsafeEff_ . k) m
82 runInterpreter es (Interpreter les $ \k -> interpreter $ unsafeEff_ . k) m
83
83
84−-- | Interpret a higher order effect with help of a function running 'Eff'
84+-- | Interpret a higher order effect with help of a function running local 'Eff'
85-- operations in 'IO'.
85-- operations in 'IO'.
86interpretIO
86interpretIO
87− :: (forall r es. HasCallStack => RunIn es IO -> e (Eff es) r -> Eff baseEs r)
87+ :: (forall r localEs. HasCallStack => RunIn localEs IO -> e (Eff localEs) r -> Eff es r)
88− -- ^ The effect handler
88+ -- ^ The effect handler.
89− -> Eff (e : baseEs) a
89+ -> Eff (e : es) a
90− -> Eff baseEs a
90+ -> Eff es a
91interpretIO interpreter m = unsafeEff $ \es -> do
91interpretIO interpreter m = unsafeEff $ \es -> do
92 les <- forkEnv es
92 les <- forkEnv es
93 runInterpreter es (Interpreter les interpreter) m
93 runInterpreter es (Interpreter les interpreter) m
@@ -95,42 +95,42 @@ interpretIO interpreter m = unsafeEff $ \es -> do
95----------------------------------------
95----------------------------------------
96-- Reinterpretation
96-- Reinterpretation
97
97
98−-- | Interpret a first order effect using local effects.
98+-- | Interpret a first order effect using other effects.
99reinterpret
99reinterpret
100− :: (Eff localEs a -> Eff baseEs b)
100+ :: (Eff handlerEs a -> Eff es b)
101− -- ^ Introduction of local effects
101+ -- ^ Introduction of effects encapsulated within the handler.
102− -> (forall r es. HasCallStack => e (Eff es) r -> Eff localEs r)
102+ -> (forall r localEs. HasCallStack => e (Eff localEs) r -> Eff handlerEs r)
103− -- ^ The effect handler
103+ -- ^ The effect handler.
104− -> Eff (e : baseEs) a
104+ -> Eff (e : es) a
105− -> Eff baseEs b
105+ -> Eff es b
106reinterpret runLocal interpreter m = unsafeEff $ \es -> do
106reinterpret runLocal interpreter m = unsafeEff $ \es -> do
107 les0 <- forkEnv es
107 les0 <- forkEnv es
108 (`unEff` les0) . runLocal . unsafeEff $ \les -> do
108 (`unEff` les0) . runLocal . unsafeEff $ \les -> do
109 runInterpreter es (Interpreter les $ \_ -> interpreter) m
109 runInterpreter es (Interpreter les $ \_ -> interpreter) m
110
110
111−-- | Interpret a higher order effect using local effects with help of a function
111+-- | Interpret a higher order effect using other effects with help of a function
112−-- running 'Eff' operations in the local 'Eff' of an effect handler.
112+-- running local 'Eff' operations in the context of an effect handler.
113reinterpretM
113reinterpretM
114− :: (Eff localEs a -> Eff baseEs b)
114+ :: (Eff handlerEs a -> Eff es b)
115− -- ^ Introduction of local effects
115+ -- ^ Introduction of effects encapsulated within the handler.
116− -> (forall r es. HasCallStack => RunIn es (Eff localEs) -> e (Eff es) r -> Eff localEs r)
116+ -> (forall r localEs. HasCallStack => RunIn localEs (Eff handlerEs) -> e (Eff localEs) r -> Eff handlerEs r)
117− -- ^ The effect handler
117+ -- ^ The effect handler.
118− -> Eff (e : baseEs) a
118+ -> Eff (e : es) a
119− -> Eff baseEs b
119+ -> Eff es b
120reinterpretM runLocal interpreter m = unsafeEff $ \es -> do
120reinterpretM runLocal interpreter m = unsafeEff $ \es -> do
121 les0 <- forkEnv es
121 les0 <- forkEnv es
122 (`unEff` les0) . runLocal . unsafeEff $ \les -> do
122 (`unEff` les0) . runLocal . unsafeEff $ \les -> do
123 runInterpreter es (Interpreter les $ \k -> interpreter $ unsafeEff_ . k) m
123 runInterpreter es (Interpreter les $ \k -> interpreter $ unsafeEff_ . k) m
124
124
125−-- | Interpret a higher order effect using local effects with help of a function
125+-- | Interpret a higher order effect using other effects with help of a function
126−-- running 'Eff' operations in 'IO'.
126+-- running local 'Eff' operations in 'IO'.
127reinterpretIO
127reinterpretIO
128− :: (Eff localEs a -> Eff baseEs b)
128+ :: (Eff handlerEs a -> Eff es b)
129− -- ^ Introduction of local effects
129+ -- ^ Introduction of effects encapsulated within the handler.
130− -> (forall r es. HasCallStack => RunIn es IO -> e (Eff es) r -> Eff localEs r)
130+ -> (forall r localEs. HasCallStack => RunIn localEs IO -> e (Eff localEs) r -> Eff handlerEs r)
131− -- ^ The effect handler
131+ -- ^ The effect handler.
132− -> Eff (e : baseEs) a
132+ -> Eff (e : es) a
133− -> Eff baseEs b
133+ -> Eff es b
134reinterpretIO runLocal interpreter m = unsafeEff $ \es -> do
134reinterpretIO runLocal interpreter m = unsafeEff $ \es -> do
135 les0 <- forkEnv es
135 les0 <- forkEnv es
136 (`unEff` les0) . runLocal . unsafeEff $ \les -> do
136 (`unEff` les0) . runLocal . unsafeEff $ \les -> do
src/Effectful/State/Dynamic.hs+8−8
@@ -61,10 +61,10 @@ execState :: s -> Eff (State s : es) a -> Eff es s
61execState s0 = reinterpretM (SP.execState s0) statePure
61execState s0 = reinterpretM (SP.execState s0) statePure
62
62
63statePure
63statePure
64− :: SP.State s :> localEs
64+ :: SP.State s :> es
65− => RunIn es (Eff localEs)
65+ => RunIn localEs (Eff es)
66− -> State s (Eff es) a
66+ -> State s (Eff localEs) a
67− -> Eff localEs a
67+ -> Eff es a
68statePure run = \case
68statePure run = \case
69 Get -> SP.get
69 Get -> SP.get
70 Put s -> SP.put s
70 Put s -> SP.put s
@@ -84,10 +84,10 @@ execStateMVar :: s -> Eff (State s : es) a -> Eff es s
84execStateMVar s0 = reinterpretM (SM.execState s0) stateMVar
84execStateMVar s0 = reinterpretM (SM.execState s0) stateMVar
85
85
86stateMVar
86stateMVar
87− :: SM.State s :> localEs
87+ :: SM.State s :> es
88− => (forall r. Eff es r -> Eff localEs r)
88+ => (forall r. Eff localEs r -> Eff es r)
89− -> State s (Eff es) a
89+ -> State s (Eff localEs) a
90− -> Eff localEs a
90+ -> Eff es a
91stateMVar run = \case
91stateMVar run = \case
92 Get -> SM.get
92 Get -> SM.get
93 Put s -> SM.put s
93 Put s -> SM.put s
src/Effectful/Writer/Dynamic.hs+8−8
@@ -34,10 +34,10 @@ execWriter :: Monoid w => Eff (Writer w : es) a -> Eff es w
34execWriter = reinterpretM WP.execWriter writerPure
34execWriter = reinterpretM WP.execWriter writerPure
35
35
36writerPure
36writerPure
37− :: (WP.Writer w :> localEs, Monoid w)
37+ :: (WP.Writer w :> es, Monoid w)
38− => RunIn es (Eff localEs)
38+ => RunIn localEs (Eff es)
39− -> Writer w (Eff es) a
39+ -> Writer w (Eff localEs) a
40− -> Eff localEs a
40+ -> Eff es a
41writerPure run = \case
41writerPure run = \case
42 Tell w -> WP.tell w
42 Tell w -> WP.tell w
43 Listen m -> WP.listen (run m)
43 Listen m -> WP.listen (run m)
@@ -52,10 +52,10 @@ execWriterMVar :: Monoid w => Eff (Writer w : es) a -> Eff es w
52execWriterMVar = reinterpretM WM.execWriter writerMVar
52execWriterMVar = reinterpretM WM.execWriter writerMVar
53
53
54writerMVar
54writerMVar
55− :: (WM.Writer w :> localEs, Monoid w)
55+ :: (WM.Writer w :> es, Monoid w)
56− => RunIn es (Eff localEs)
56+ => RunIn localEs (Eff es)
57− -> Writer w (Eff es) a
57+ -> Writer w (Eff localEs) a
58− -> Eff localEs a
58+ -> Eff es a
59writerMVar run = \case
59writerMVar run = \case
60 Tell w -> WM.tell w
60 Tell w -> WM.tell w
61 Listen m -> WM.listen (run m)
61 Listen m -> WM.listen (run m)