Skip to content

Commit 5e4e6d3

Browse files
committed
Add @freebroccolo's Distributive instance
From purescript/purescript-distributive#4
1 parent ba2a0b8 commit 5e4e6d3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
"output",
2828
"test",
2929
"bower.json",
30-
"gulpfile.js",
3130
"package.json"
3231
],
3332
"dependencies": {
33+
"purescript-distributive": "^0.5.0",
3434
"purescript-lazy": "^0.4.0",
3535
"purescript-tailrec": "^0.3.0",
3636
"purescript-unfoldable": "^0.4.0"

src/Control/Monad/Reader/Trans.purs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import Prelude
66

77
import Control.Alt
88
import Control.Alternative
9-
import Control.Plus
9+
import Control.Monad.Eff.Class
1010
import Control.Monad.Trans
1111
import Control.MonadPlus
12-
import Control.Monad.Eff.Class
12+
import Control.Plus
13+
import Data.Distributive (Distributive, distribute, collect)
1314

1415
-- | The reader monad transformer.
1516
-- |
@@ -63,6 +64,10 @@ instance monadTransReaderT :: MonadTrans (ReaderT r) where
6364
instance monadEffReader :: (Monad m, MonadEff eff m) => MonadEff eff (ReaderT r m) where
6465
liftEff = lift <<< liftEff
6566

67+
instance distributiveReaderT :: (Distributive g) => Distributive (ReaderT e g) where
68+
distribute a = ReaderT \e -> collect (flip runReaderT e) a
69+
collect f = distribute <<< map f
70+
6671
liftReaderT :: forall r m a. m a -> ReaderT r m a
6772
liftReaderT m = ReaderT (const m)
6873

0 commit comments

Comments
 (0)