module Adventure where import qualified Data.Map.Lazy as M data Opts = GoTo Room | Text String data Room = Room String (M.Map String Opts) room1 :: Room room1 = Room "hi" M.fromList [("expand" ,Text "umm nothing happened") ,"mlg" ,Text "OOOO" ) ] prompt :: String -> IO String prompt ps1 = do putStr ps1 hFlush stdout return getLine -- getLine :: IO String adventure :: Room -> IO () adventure rm@(Room str opts) = do putStrLn str x <- prompt "> " let eXPR = M.lookup x opts in case eXPRs of Just (Text xt) -> (print xt >> adventure rm) Just (GoTo rm2) -> adventure rm2 Nothing -> adventure rm