Commit a247dcfe authored by Oleg Grenrus's avatar Oleg Grenrus

Resolve #6375: Let export safe* from both Utils.Generic and Simple.Utils

So we do with many other stuff
parent 0dda5b99
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -154,6 +154,8 @@ module Distribution.Simple.Utils (
ordNubRight,
safeHead,
safeTail,
safeLast,
safeInit,
unintersperse,
wrapText,
wrapLine,
......
......@@ -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 [_] = []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment