summaryrefslogtreecommitdiff
path: root/src/Sequence/Formula.hs
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-06-14 11:53:42 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2016-06-14 11:53:42 +0200
commit583f6cddc1c17bd93bb7b33cb1a5210fc330ff0f (patch)
treefbea91dff8e16fcda9df8d9632db35b5ab0877c2 /src/Sequence/Formula.hs
parentd196ace4100ec5f8cfb0fad265d3baa44873fc9d (diff)
download2017-01-16_17:13:37-583f6cddc1c17bd93bb7b33cb1a5210fc330ff0f.tar
2017-01-16_17:13:37-583f6cddc1c17bd93bb7b33cb1a5210fc330ff0f.tar.gz
2017-01-16_17:13:37-583f6cddc1c17bd93bb7b33cb1a5210fc330ff0f.tar.bz2
2017-01-16_17:13:37-583f6cddc1c17bd93bb7b33cb1a5210fc330ff0f.tar.xz
2017-01-16_17:13:37-583f6cddc1c17bd93bb7b33cb1a5210fc330ff0f.zip
cleanup
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)