Skip to content

Commit 33c8fc2

Browse files
committed
Add ((->) r') as a base monad for SelectT.
`Identity` is the obvious choice, but we can pass arguments below `SelectT`. We should be able to even use arbitrary `ReaderT` stacks below `SelectT`.
1 parent 37cbd92 commit 33c8fc2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Control/Monad/Select.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ class (Monad m) => MonadSelect r m | m -> r where
125125
instance MonadSelect r (SelectT r Identity) where
126126
select = Select.select
127127

128+
instance MonadSelect r (SelectT r ((->) r')) where
129+
select f = SelectT $ \k r' -> f $ \ma -> k ma r'
130+
128131
-- | \'Extends\' the possibilities considered by @m@ to include 'Nothing'; this
129132
-- means that 'Nothing' gains a \'rank\' (namely, a value of @r@), and the
130133
-- potential result could also be 'Nothing'.

0 commit comments

Comments
 (0)