From 57b4c2d805b784c011e150d19a417eee693a5090 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Wed, 15 Feb 2023 22:45:23 -0500 Subject: [PATCH] REF use text fun --- app/rofi-dev.hs | 2 +- lib/Rofi/Command.hs | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/app/rofi-dev.hs b/app/rofi-dev.hs index 50fb765..76af2a5 100644 --- a/app/rofi-dev.hs +++ b/app/rofi-dev.hs @@ -808,7 +808,7 @@ isDirMounted fp = elem fp <$> curMountpoints -- Other functions fromLines :: (T.Text -> Maybe a) -> [T.Text] -> [a] -fromLines f = mapMaybe (f . stripWS) +fromLines f = mapMaybe (f . T.strip) -- TODO this exists somewhere... -- splitBy :: Char -> T.Text -> [T.Text] diff --git a/lib/Rofi/Command.hs b/lib/Rofi/Command.hs index ea6edff..1830a12 100644 --- a/lib/Rofi/Command.hs +++ b/lib/Rofi/Command.hs @@ -19,12 +19,10 @@ module Rofi.Command , readCmdEither' , dmenuArgs , joinNewline - , stripWS , runRofi ) where -import Data.Char import qualified Data.Map.Ordered as M import RIO import qualified RIO.List as L @@ -172,12 +170,9 @@ readCmdEither' cmd args input environ = resultToEither :: (ExitCode, String, String) -> Either (Int, T.Text, T.Text) T.Text -resultToEither (ExitSuccess, out, _) = Right $ stripWS $ T.pack out +resultToEither (ExitSuccess, out, _) = Right $ T.strip $ T.pack out resultToEither (ExitFailure n, out, err) = - Left (n, stripWS $ T.pack out, stripWS $ T.pack err) - -stripWS :: T.Text -> T.Text -stripWS = T.reverse . T.dropWhile isSpace . T.reverse + Left (n, T.strip $ T.pack out, T.strip $ T.pack err) joinNewline :: [T.Text] -> T.Text joinNewline = T.intercalate "\n"