Skip to content

Commit b7d8848

Browse files
committed
Add ((->) r') as a base monad for SelectT.
`Identity` is the obvious choice, but we can pass an argument below `SelectT`.
1 parent 37cbd92 commit b7d8848

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 = Select.SelectT $ \k r' -> f $ \a -> k a 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)