From 2facde23774a6d47c45bb20425645cfafc3179e5 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sat, 4 Mar 2023 19:01:57 -0800 Subject: [PATCH] Update test code --- test/Main.purs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/Main.purs b/test/Main.purs index 7ac79f1..7249106 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -4,12 +4,11 @@ import Prelude import Control.Alternative (guard, (<|>)) import Control.Monad.Logic.Class (class MonadLogic, interleave) -import Control.Monad.Logic.Trans (SFKT, runSFKT) +import Control.Monad.Logic.Trans (runSFKT) import Control.Monad.Reader.Class (class MonadReader) import Control.Monad.Reader.Trans (runReaderT, ask) import Control.Monad.State.Class (class MonadState) import Control.Monad.State.Trans (runStateT, put, get) -import Data.List (List(..), (:)) import Data.Maybe (Maybe) import Data.Tuple (fst) import Data.Tuple.Nested(type (/\), (/\)) @@ -26,17 +25,14 @@ test = newState <- get pure ((offset+n) /\ (oldState <> " became " <> newState)) -solutions :: forall a m. Monad m => SFKT m a -> m (List a) -solutions m = runSFKT m ((<$>) <<< (:)) (pure Nil) - order1 :: Maybe String -order1 = show <$> (runReaderT (solutions (fst <$> runStateT (test >>= \(x /\ s) -> guard (x `mod` 2 == 1) >>= \_ -> pure (x /\ s)) "initial")) 11) +order1 = show <$> (runReaderT (runSFKT (fst <$> runStateT (test >>= \(x /\ s) -> guard (x `mod` 2 == 1) >>= \_ -> pure (x /\ s)) "initial")) 11) order2 :: Maybe String -order2 = show <$> fst <$> (runStateT (runReaderT (solutions (test >>= \(x /\ s) -> guard (x `mod` 2 == 1) >>= \_ -> pure (x /\ s))) 11) "initial") +order2 = show <$> fst <$> (runStateT (runReaderT (runSFKT (test >>= \(x /\ s) -> guard (x `mod` 2 == 1) >>= \_ -> pure (x /\ s))) 11) "initial") order3 :: Maybe String -order3 = show <$> fst <$> (runStateT (runReaderT (solutions test) 0) "initial") +order3 = show <$> fst <$> (runStateT (runReaderT (runSFKT test) 0) "initial") main :: Maybe String main = order1