diff --git a/src/Control/Monad/Logic/Trans.purs b/src/Control/Monad/Logic/Trans.purs index f0f5208..6643547 100644 --- a/src/Control/Monad/Logic/Trans.purs +++ b/src/Control/Monad/Logic/Trans.purs @@ -1,6 +1,6 @@ module Control.Monad.Logic.Trans (SFKT, runSFKT, runSFKTOnce) where -import Prelude (class Applicative, class Apply, class Bind, class Functor, class Monad, bind, pure, ($), (<<<), (>>=)) +import Prelude (class Applicative, class Apply, class Bind, class Functor, class Monad, bind, pure, ($), (<<<), (>>=), const) import Control.Monad.Logic.Class import Control.MonadPlus (class MonadPlus, class Alternative, class Alt, class Plus, (<|>), empty) @@ -24,11 +24,11 @@ newtype SFKT m a = SFKT (forall ans. SK (m ans) a -> FK (m ans) -> m ans) unSFKT :: forall a m. SFKT m a -> forall ans. SK (m ans) a -> FK (m ans) -> m ans unSFKT (SFKT f) = f -runSFKT :: forall a m. Applicative m => SFKT m a -> m (List a) -runSFKT (SFKT f) = f (map <<< (:)) (pure Nil) - runSFKTOnce :: forall a m. Alternative m => SFKT m a -> m a -runSFKTOnce (SFKT f) = f ((<|>) <<< pure) empty +runSFKTOnce (SFKT f) = f (const <<< pure) empty + +runSFKT :: forall a m. Monad m => SFKT m a -> m (List a) +runSFKT (SFKT f) = f (map <<< (:)) (pure Nil) instance Functor (SFKT m) where map f m = SFKT (\sk -> unSFKT m (\a -> sk (f a)))