From b7d88484363600d0706efebbe4941660d552bc38 Mon Sep 17 00:00:00 2001 From: Felix Springer Date: Fri, 13 Jan 2023 11:29:05 +0100 Subject: [PATCH] Add `((->) r')` as a base monad for `SelectT`. `Identity` is the obvious choice, but we can pass an argument below `SelectT`. --- Control/Monad/Select.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Control/Monad/Select.hs b/Control/Monad/Select.hs index 4896042..65ecf9f 100644 --- a/Control/Monad/Select.hs +++ b/Control/Monad/Select.hs @@ -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'.