summaryrefslogtreecommitdiff
path: root/src/Sequence/Utils.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Sequence/Utils.hs')
-rw-r--r--src/Sequence/Utils.hs17
1 files changed, 2 insertions, 15 deletions
diff --git a/src/Sequence/Utils.hs b/src/Sequence/Utils.hs
index f0a8849..274a69d 100644
--- a/src/Sequence/Utils.hs
+++ b/src/Sequence/Utils.hs
@@ -2,8 +2,8 @@
2 2
3module Sequence.Utils 3module Sequence.Utils
4 ( withArg, withFocus 4 ( withArg, withFocus
5 , askQ, askBool
6 , toName, fromName 5 , toName, fromName
6 , module Sequence.Utils.Ask
7 ) where 7 ) where
8 8
9import Sequence.Types 9import Sequence.Types
@@ -33,8 +33,7 @@ import System.Console.Shell
33import System.Console.Shell.ShellMonad 33import System.Console.Shell.ShellMonad
34import System.Console.Shell.Backend.Haskeline 34import System.Console.Shell.Backend.Haskeline
35 35
36import System.Console.Readline (readline) 36import Sequence.Utils.Ask
37
38 37
39class Argument a st | a -> st where 38class Argument a st | a -> st where
40 arg :: String -> Sh st (Maybe a) 39 arg :: String -> Sh st (Maybe a)
@@ -49,18 +48,6 @@ withFocus f = use gFocus >>= \focus -> case focus of
49 Nothing -> shellPutErrLn $ "Currently not focusing any entity" 48 Nothing -> shellPutErrLn $ "Currently not focusing any entity"
50 Just id -> f id 49 Just id -> f id
51 50
52askBool :: MonadIO m => String -> Bool -> m Bool
53askBool prompt initial = askQ prompt $ fromMaybe initial . join . fmap (eval . CI.mk)
54 where
55 eval "yes" = Just True
56 eval "y" = Just True
57 eval "no" = Just False
58 eval "n" = Just False
59 eval _ = Nothing
60
61askQ :: MonadIO m => String -> (Maybe String -> a) -> m a
62askQ prompt eval = eval <$> liftIO (readline $ prompt ++ " ")
63
64unaligned = view faction' def 51unaligned = view faction' def
65 52
66toName :: MonadState GameState m => EntityIdentifier -> m String 53toName :: MonadState GameState m => EntityIdentifier -> m String