summaryrefslogtreecommitdiffstats
path: root/src/Main.hs
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-07-29 08:49:42 +0200
committertv <tv@shackspace.de>2014-07-29 08:49:42 +0200
commit627894eacfba83bc820d5605b2a33d59c7c7e969 (patch)
treea08de2f04d4d8699248332cb78338317b68e807f /src/Main.hs
parenta30e97644079226e91614e70bef9e895e79a189f (diff)
rewrite (concat $ map f xs) to (xs >>= f)
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/Main.hs b/src/Main.hs
index f170492..6cac6fc 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -81,7 +81,7 @@ uiThread cf putState getState = forever $ do
--t1 <- getCurrentTime
--putStrLn $ "====> \ESC[32;1m" ++ show s ++ "\ESC[m in " ++
-- (show $ diffUTCTime t1 t0)
- -- ++ ": \"\ESC[35m" ++ (concat $ map (colorize . toChar) s)
+ -- ++ ": \"\ESC[35m" ++ (s >>= colorize . toChar)
-- ++ "\ESC[m\""
--case res of
-- Left msg -> putStrLn $ " error: " ++ msg
@@ -158,14 +158,13 @@ prettyError e = rec e
color cc s = "\x1b[" ++ cc ++ "m" ++ s ++ "\x1b[m"
rec (UnhandledInputError s) =
- color "31" $ "unhandled input: <" ++ (pp "31;1" s) ++ "\x1b[;31m>"
+ color "31" $ "unhandled input: <" ++ (s >>= pp "31;1") ++ "\x1b[;31m>"
rec (OtherError s) =
color "31" $ "error: " ++ s
-- TODO cc is ColorCode
- pp cc = concat . map (pp1 cc)
- pp1 cc c
+ pp cc c
| isPrint c = [c]
| otherwise = specialChar cc $
case c of
@@ -242,7 +241,7 @@ execCommand ExecuteInputBuffer = do
tell [ show s ]
'!' : cmdline -> do
--tell [ "spawn: " ++ cmdline ]
- -- "input: <" ++ (concat $ map (reform 32) $ showBuffer b) ++ ">" ]
+ -- "input: <" ++ (showBuffer b >>= reform 32) ++ ">" ]
-- TODO register process
i <- state $ \ q ->
let i = processCount q + 1
@@ -253,7 +252,7 @@ execCommand ExecuteInputBuffer = do
"" -> do
liftIO ringBell
s -> do
- tell [ "input: <" ++ (concat $ map (reform 32) s) ++ ">" ]
+ tell [ "input: <" ++ (s >>= reform 32) ++ ">" ]
modifyBuffer (const emptyBuffer)
@@ -333,11 +332,9 @@ renderInputLine m (lhs, rhs) = do
InsertMode -> "> "
VerbatimMode -> "\x1b[34;1m^\x1b[m "
- putStr $ promptString ++ pp lhs ++ pp rhs
- moveCursorLeft (length $ ppVis rhs)
+ putStr $ promptString ++ (lhs >>= reform') ++ (rhs >>= reform')
+ moveCursorLeft (length $ rhs >>= reformVis)
where
- pp = concat . map reform'
-
-- TODO unify reform and reform'
reform' c =
if isPrint c
@@ -349,7 +346,6 @@ renderInputLine m (lhs, rhs) = do
_ -> charToCode c
) ++ "\x1b[m"
- ppVis = concat . map reformVis
reformVis c =
if isPrint c
then [c]