crem-0.1.0.0: hobbit-game/Main.hs
{-# LANGUAGE DataKinds #-}
module Main where
import "base" Data.Functor.Identity
import "crem" Crem.Example.TheHobbit
import "crem" Crem.StateMachine
main :: IO ()
main = do
putStrLn "Welcome to the Hobbit adventure game!"
let
initialState :: HobbitState 'TunnelLikeHall
initialState = TunnelLikeHallState
initialMessage :: String
initialMessage = getMessage $ stateMessage initialState
putStrLn initialMessage
loop (Basic $ hobbitMachine initialState)
where
loop :: StateMachineT Identity HobbitCommand HobbitMessage -> IO ()
loop machine = do
command <- readLn
let
(message, machine') = runIdentity $ run machine command
putStrLn $ getMessage message
loop machine'