Skip to content

Commit

Permalink
Add ((->) r') as a base monad for SelectT.
Browse files Browse the repository at this point in the history
`Identity` is the obvious choice, but we can pass an argument below
`SelectT`.
  • Loading branch information
jumper149 committed Jan 14, 2023
1 parent 37cbd92 commit b7d8848
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Control/Monad/Select.hs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ class (Monad m) => MonadSelect r m | m -> r where
instance MonadSelect r (SelectT r Identity) where
select = Select.select

instance MonadSelect r (SelectT r ((->) r')) where
select f = Select.SelectT $ \k r' -> f $ \a -> k a r'

-- | \'Extends\' the possibilities considered by @m@ to include 'Nothing'; this
-- means that 'Nothing' gains a \'rank\' (namely, a value of @r@), and the
-- potential result could also be 'Nothing'.
Expand Down

0 comments on commit b7d8848

Please sign in to comment.