diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-06-03 22:09:01 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-06-03 22:09:01 +0200 |
commit | cfb7be14aebffd68ca357d7c6ef15e1c0974a156 (patch) | |
tree | 7448ef0ee0fa4049903efabf2fe7abf8eb7940b3 /src/Sequence/Utils.hs | |
parent | a98cd5d87a0c7959146a8ca35aa40f42fc146ad8 (diff) | |
download | 2017-01-16_17:13:37-cfb7be14aebffd68ca357d7c6ef15e1c0974a156.tar 2017-01-16_17:13:37-cfb7be14aebffd68ca357d7c6ef15e1c0974a156.tar.gz 2017-01-16_17:13:37-cfb7be14aebffd68ca357d7c6ef15e1c0974a156.tar.bz2 2017-01-16_17:13:37-cfb7be14aebffd68ca357d7c6ef15e1c0974a156.tar.xz 2017-01-16_17:13:37-cfb7be14aebffd68ca357d7c6ef15e1c0974a156.zip |
cleanup & stumped on variadic val
Diffstat (limited to 'src/Sequence/Utils.hs')
-rw-r--r-- | src/Sequence/Utils.hs | 17 |
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 | ||
3 | module Sequence.Utils | 3 | module 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 | ||
9 | import Sequence.Types | 9 | import Sequence.Types |
@@ -33,8 +33,7 @@ import System.Console.Shell | |||
33 | import System.Console.Shell.ShellMonad | 33 | import System.Console.Shell.ShellMonad |
34 | import System.Console.Shell.Backend.Haskeline | 34 | import System.Console.Shell.Backend.Haskeline |
35 | 35 | ||
36 | import System.Console.Readline (readline) | 36 | import Sequence.Utils.Ask |
37 | |||
38 | 37 | ||
39 | class Argument a st | a -> st where | 38 | class 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 | ||
52 | askBool :: MonadIO m => String -> Bool -> m Bool | ||
53 | askBool 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 | |||
61 | askQ :: MonadIO m => String -> (Maybe String -> a) -> m a | ||
62 | askQ prompt eval = eval <$> liftIO (readline $ prompt ++ " ") | ||
63 | |||
64 | unaligned = view faction' def | 51 | unaligned = view faction' def |
65 | 52 | ||
66 | toName :: MonadState GameState m => EntityIdentifier -> m String | 53 | toName :: MonadState GameState m => EntityIdentifier -> m String |