REF use text fun

This commit is contained in:
Nathan Dwarshuis 2023-02-15 22:45:23 -05:00
parent b6f32a1b0f
commit 57b4c2d805
2 changed files with 3 additions and 8 deletions

View File

@ -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]

View File

@ -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"