summaryrefslogtreecommitdiff
path: root/src/Sequence/Formula.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Sequence/Formula.hs')
-rw-r--r--src/Sequence/Formula.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/Sequence/Formula.hs b/src/Sequence/Formula.hs
index be5032a..a3675c6 100644
--- a/src/Sequence/Formula.hs
+++ b/src/Sequence/Formula.hs
@@ -103,9 +103,10 @@ quot' = liftM2 quot
103askQuestion :: (MonadIO m, sInput :<: lInput) => [String] -> (lInput, Maybe (Formula sInput)) -> Question sInput -> m (lInput, Maybe (Formula sInput)) 103askQuestion :: (MonadIO m, sInput :<: lInput) => [String] -> (lInput, Maybe (Formula sInput)) -> Question sInput -> m (lInput, Maybe (Formula sInput))
104askQuestion promptPref input q@(Question{..}) = flip (if keepResult then set $ _1 . ctx' . answer else set _2 . Just) input . maybe (throwError q) return <$> askQ (wPromptPref $ promptPref ++ prompt) (join . fmap readMaybe) 104askQuestion promptPref input q@(Question{..}) = flip (if keepResult then set $ _1 . ctx' . answer else set _2 . Just) input . maybe (throwError q) return <$> askQ (wPromptPref $ promptPref ++ prompt) (join . fmap readMaybe)
105 where 105 where
106 wPromptPref [] = " »" 106 wPromptPref [] = " " ++ sep
107 wPromptPref [x] = x ++ " »" 107 wPromptPref [x] = x ++ " " ++ sep
108 wPromptPref (x:xs) = x ++ " » " ++ wPromptPref xs 108 wPromptPref (x:xs) = x ++ " " ++ sep ++ " " ++ wPromptPref xs
109 sep = "»"
109 110
110evalFormula :: (MonadIO m, sInput :<: lInput) => [String] -> lInput -> FormulaM sInput a -> m (lInput, a) 111evalFormula :: (MonadIO m, sInput :<: lInput) => [String] -> lInput -> FormulaM sInput a -> m (lInput, a)
111evalFormula promptPref input = evalFormula' [] promptPref (input, Nothing) 112evalFormula promptPref input = evalFormula' [] promptPref (input, Nothing)