Skip to content

Commit a6765f4

Browse files
committed
Simplify MonadRec instance for ReaderT
1 parent 9f33bee commit a6765f4

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/Control/Monad/Reader/Trans.purs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,8 @@ instance distributiveReaderT :: (Distributive g) => Distributive (ReaderT e g) w
102102
collect f = distribute <<< map f
103103

104104
instance monadRecReaderT :: (MonadRec m) => MonadRec (ReaderT r m) where
105-
tailRecM k a = ReaderT \r -> tailRecM k' (Tuple a r)
105+
tailRecM k a = ReaderT \r -> tailRecM (k' r) a
106106
where
107-
k' (Tuple a r) = do
107+
k' r a = do
108108
result <- runReaderT (k a) r
109-
return case result of
110-
Left a -> Left (Tuple a r)
111-
Right b -> Right b
109+
return $ either Left Right result

0 commit comments

Comments
 (0)