getting closer...

This commit is contained in:
Yehowshua Immanuel 2025-02-19 09:06:40 -05:00
parent 32932f4816
commit f9248057f9
7 changed files with 107 additions and 51 deletions

View file

@ -12,22 +12,27 @@ import Data.Maybe (listToMaybe)
import Data.List (isPrefixOf)
import Text.Show.Pretty (ppShow)
import Simulation (simulation, Args(..))
import Simulation (simulation, Args(..), Simulation(..))
main :: IO ()
main = do
rawArgs <- getArgs
args <- parseArgs rawArgs
states <- simulation args
simResult <- simulation args
putStrLn "Simulating Machine"
-- mapM_ (putStrLn . ppShow) states -- Uncomment to print each state, if needed.
putStrLn $ "Last state: " ++ show (last states)
putStrLn $ "Executed for " ++ show (length states) ++ " cycles"
putStrLn "Simulation complete"
case simResult of
Success states -> do
-- mapM_ (putStrLn . ppShow) states -- Uncomment to print each state, if needed.
putStrLn $ "Last state: " ++ show (last states)
putStrLn $ "Executed for " ++ show (length states) ++ " cycles"
putStrLn "Simulation complete"
Failure err -> do
putStrLn $ "Simulation failed: " ++ err
exitFailure
-- Function to parse command line arguments into the Args data type
parseArgs :: [String] -> IO Args
parseArgs argv =
parseArgs argv =
case extractKey "firmware" argv of
Just firmwarePath -> return Args { firmware = firmwarePath }
Nothing -> do