diff --git a/Cabal/Distribution/PackageDescription/Check.hs b/Cabal/Distribution/PackageDescription/Check.hs index f2963dbb308..25f65224a1a 100644 --- a/Cabal/Distribution/PackageDescription/Check.hs +++ b/Cabal/Distribution/PackageDescription/Check.hs @@ -56,7 +56,7 @@ import Distribution.Types.CondTree import Distribution.Types.ExeDependency import Distribution.Types.LibraryName import Distribution.Types.UnqualComponentName -import Distribution.Utils.Generic (isAscii, safeInit) +import Distribution.Utils.Generic (isAscii) import Distribution.Verbosity import Distribution.Version import Language.Haskell.Extension diff --git a/Cabal/Distribution/Simple/Compiler.hs b/Cabal/Distribution/Simple/Compiler.hs index d338a2c8e03..fd0e05af8bd 100644 --- a/Cabal/Distribution/Simple/Compiler.hs +++ b/Cabal/Distribution/Simple/Compiler.hs @@ -73,7 +73,6 @@ module Distribution.Simple.Compiler ( import Prelude () import Distribution.Compat.Prelude -import Distribution.Utils.Generic(safeLast) import Distribution.Pretty import Distribution.Compiler diff --git a/Cabal/Distribution/Simple/Configure.hs b/Cabal/Distribution/Simple/Configure.hs index 33bd9c9362b..39570332d65 100644 --- a/Cabal/Distribution/Simple/Configure.hs +++ b/Cabal/Distribution/Simple/Configure.hs @@ -102,7 +102,6 @@ import Distribution.Backpack.DescribeUnitId import Distribution.Backpack.PreExistingComponent import Distribution.Backpack.ConfiguredComponent (newPackageDepsBehaviour) import Distribution.Backpack.Id -import Distribution.Utils.Generic import Distribution.Utils.LogProgress import qualified Distribution.Simple.GHC as GHC diff --git a/Cabal/Distribution/Simple/HaskellSuite.hs b/Cabal/Distribution/Simple/HaskellSuite.hs index b1be692b3a0..787b3edb0ea 100644 --- a/Cabal/Distribution/Simple/HaskellSuite.hs +++ b/Cabal/Distribution/Simple/HaskellSuite.hs @@ -26,7 +26,6 @@ import Distribution.PackageDescription import Distribution.Simple.LocalBuildInfo import Distribution.System (Platform) import Distribution.Compat.Exception -import Distribution.Utils.Generic import Language.Haskell.Extension import Distribution.Simple.Program.Builtin diff --git a/Cabal/Distribution/Simple/Utils.hs b/Cabal/Distribution/Simple/Utils.hs index 9912edecc83..01f81c1969e 100644 --- a/Cabal/Distribution/Simple/Utils.hs +++ b/Cabal/Distribution/Simple/Utils.hs @@ -154,6 +154,8 @@ module Distribution.Simple.Utils ( ordNubRight, safeHead, safeTail, + safeLast, + safeInit, unintersperse, wrapText, wrapLine, diff --git a/Cabal/Distribution/Utils/Generic.hs b/Cabal/Distribution/Utils/Generic.hs index 11da74d198d..993dfa9b69a 100644 --- a/Cabal/Distribution/Utils/Generic.hs +++ b/Cabal/Distribution/Utils/Generic.hs @@ -369,21 +369,29 @@ listUnionRight a b = ordNubRight (filter (`Set.notMember` bSet) a) ++ b bSet = Set.fromList b -- | A total variant of 'head'. +-- +-- @since 3.2.0.0 safeHead :: [a] -> Maybe a safeHead [] = Nothing safeHead (x:_) = Just x -- | A total variant of 'tail'. +-- +-- @since 3.2.0.0 safeTail :: [a] -> [a] safeTail [] = [] safeTail (_:xs) = xs -- | A total variant of 'last'. +-- +-- @since 3.2.0.0 safeLast :: [a] -> Maybe a safeLast [] = Nothing safeLast (x:xs) = Just (foldl (\_ a -> a) x xs) -- | A total variant of 'init'. +-- +-- @since 3.2.0.0 safeInit :: [a] -> [a] safeInit [] = [] safeInit [_] = []