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 -- Other functions
fromLines :: (T.Text -> Maybe a) -> [T.Text] -> [a] fromLines :: (T.Text -> Maybe a) -> [T.Text] -> [a]
fromLines f = mapMaybe (f . stripWS) fromLines f = mapMaybe (f . T.strip)
-- TODO this exists somewhere... -- TODO this exists somewhere...
-- splitBy :: Char -> T.Text -> [T.Text] -- splitBy :: Char -> T.Text -> [T.Text]

View File

@ -19,12 +19,10 @@ module Rofi.Command
, readCmdEither' , readCmdEither'
, dmenuArgs , dmenuArgs
, joinNewline , joinNewline
, stripWS
, runRofi , runRofi
) )
where where
import Data.Char
import qualified Data.Map.Ordered as M import qualified Data.Map.Ordered as M
import RIO import RIO
import qualified RIO.List as L import qualified RIO.List as L
@ -172,12 +170,9 @@ readCmdEither' cmd args input environ =
resultToEither resultToEither
:: (ExitCode, String, String) :: (ExitCode, String, String)
-> Either (Int, T.Text, T.Text) T.Text -> 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) = resultToEither (ExitFailure n, out, err) =
Left (n, stripWS $ T.pack out, stripWS $ T.pack err) Left (n, T.strip $ T.pack out, T.strip $ T.pack err)
stripWS :: T.Text -> T.Text
stripWS = T.reverse . T.dropWhile isSpace . T.reverse
joinNewline :: [T.Text] -> T.Text joinNewline :: [T.Text] -> T.Text
joinNewline = T.intercalate "\n" joinNewline = T.intercalate "\n"