Skip to content

Commit

Permalink
Updated TeLLeR so that the user can print the environment and add new…
Browse files Browse the repository at this point in the history
… resources

while choosing action alternatives.
  • Loading branch information
jff committed May 7, 2015
1 parent 4101073 commit 4e47e9a
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/Reductions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,29 @@ chooseActionToFocusOn :: [Term] -> ProverStateIO ()
chooseActionToFocusOn [] = return ()
chooseActionToFocusOn l = do
lift $ printListOfActions l
let sizeList = length l

-- JFF: Cindy wants to be able to print the state and to add new resources at this point
-- TODO: refactor the code...

lift $ tellerPrintLn "p) Print environment"
lift $ tellerPrintLn "+) Add resources (e.g. +A A-@B A-@C)"
option <- lift $ getLine -- TODO CHANGE FOR READLINE

-- user selects printing option
when ((head option) == 'p') $ do
state <- get
lift (tellerPrintLn (showState state))
-- TODO: something weird is happening with IO (possibly related with Readline): p is being read
-- twice!

when ((head option) == '+') $ do
changeEnvWith addToEnv (drop 1 option)

-- Adding new actions can add new enabled actions!
context <- gets env
let l = listEnabledActions context
let sizeList = length l

if (isValidActionChoice option sizeList) then
do
let index = fst $ head (reads option :: [(Int, String)])
Expand All @@ -152,7 +173,7 @@ chooseActionToFocusOn l = do
put $ state { env = newEnv, unfocused = unFocus }
return ()
else do
lift $ tellerWarning "Invalid Choice. Try again!"
lift $ tellerWarning $ "Choose an action from 0 to " ++ (show (sizeList-1) ++ " to proceed!")
chooseActionToFocusOn l


Expand Down

0 comments on commit 4e47e9a

Please sign in to comment.