From: Neil Smith Date: Wed, 21 Dec 2016 15:59:32 +0000 (+0000) Subject: Tidying X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=b66f0f79e01057fcb153ac16ce13ff50943a6d02;p=advent-of-code-16.git Tidying --- diff --git a/advent21.hs b/advent21.hs index fdb1381..d51bd10 100644 --- a/advent21.hs +++ b/advent21.hs @@ -1,6 +1,5 @@ import Text.Parsec hiding (State) import Text.ParserCombinators.Parsec.Number --- import Control.Applicative ((<*), (*>), (<*>)) import Data.Maybe (fromJust) import Data.List (elemIndex) @@ -58,15 +57,19 @@ main = do part1 :: [Instruction] -> String -> IO () part1 instructions start = - let state = Password {password = start} - in print $ runIdentity (runStateT (runWriterT (apply instructions)) state) - -- in putStrLn $ password $ runIdentity (execStateT (runWriterT (apply instructions)) state) + let st = Password {password = start} + ((_, log), st') = runIdentity (runStateT (runWriterT (apply instructions)) st) + in do + -- putStrLn $ unlines $ map (action) log + putStrLn $ password st' part2 :: [Instruction] -> String -> IO () part2 instructions end = - let state = Password {password = end} - in print $ runIdentity (runStateT (runWriterT (unApply instructions)) state) - -- in putStrLn $ password $ runIdentity (execStateT (runWriterT (apply instructions)) state) + let st = Password {password = end} + ((_, log), st') = runIdentity (runStateT (runWriterT (unApply instructions)) st) + in do + -- putStrLn $ unlines $ map (action) log + putStrLn $ password st' apply :: [Instruction] -> App ()