Skip to content

Commit

Permalink
Use unsnoc from Cabal-syntax Utils.Generic
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Dec 24, 2024
1 parent f08895e commit c792f3a
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions cabal-testsuite/src/Test/Cabal/NeedleHaystack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import qualified Prelude (unlines)
import Data.List (tails)
import Data.Maybe (isJust)
import Distribution.System
import Distribution.Utils.Generic (unsnoc)
import Data.List (isPrefixOf)
import qualified System.FilePath.Posix as Posix
import qualified System.FilePath.Windows as Windows
Expand Down Expand Up @@ -113,12 +114,6 @@ normalizePathSeparators =
unlines :: [String] -> String
unlines = maybe "" fst . unsnoc . Prelude.unlines

-- | @unsnoc@ is only in base >= 4.19 so we copy its definition here rather than
-- use CPP to conditionally import because we want to avoid CPP as that
-- interferes with string gaps in doctests.
unsnoc :: [a] -> Maybe ([a], a)
unsnoc = foldr (\x -> Just . maybe ([], x) (\(~(a, b)) -> (x : a, b))) Nothing

-- | Replace line CRLF line breaks with LF line breaks.
--
-- >>> encodeLf "foo\nbar\r\nbaz"
Expand Down

0 comments on commit c792f3a

Please sign in to comment.