Skip to content

Commit 639738b

Browse files
authored
Merge pull request #6552 from phadej/prelude-io
Remove WithCallStack IO type alias
2 parents 6c64494 + 2520aff commit 639738b

30 files changed

+119
-126
lines changed

Cabal/Distribution/Compat/CopyFile.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ import System.IO
6969
import qualified System.Win32.File as Win32 ( copyFile )
7070
#endif /* mingw32_HOST_OS */
7171

72-
copyOrdinaryFile, copyExecutableFile :: FilePath -> FilePath -> NoCallStackIO ()
72+
copyOrdinaryFile, copyExecutableFile :: FilePath -> FilePath -> IO ()
7373
copyOrdinaryFile src dest = copyFile src dest >> setFileOrdinary dest
7474
copyExecutableFile src dest = copyFile src dest >> setFileExecutable dest
7575

76-
setFileOrdinary, setFileExecutable, setDirOrdinary :: FilePath -> NoCallStackIO ()
76+
setFileOrdinary, setFileExecutable, setDirOrdinary :: FilePath -> IO ()
7777
#ifndef mingw32_HOST_OS
7878
setFileOrdinary path = setFileMode path 0o644 -- file perms -rw-r--r--
7979
setFileExecutable path = setFileMode path 0o755 -- file perms -rwxr-xr-x
8080

81-
setFileMode :: FilePath -> FileMode -> NoCallStackIO ()
81+
setFileMode :: FilePath -> FileMode -> IO ()
8282
setFileMode name m =
8383
withFilePath name $ \s -> do
8484
throwErrnoPathIfMinus1_ "setFileMode" name (c_chmod s m)
@@ -91,7 +91,7 @@ setDirOrdinary = setFileExecutable
9191

9292
-- | Copies a file to a new destination.
9393
-- Often you should use `copyFileChanged` instead.
94-
copyFile :: FilePath -> FilePath -> NoCallStackIO ()
94+
copyFile :: FilePath -> FilePath -> IO ()
9595
copyFile fromFPath toFPath =
9696
copy
9797
`catchIO` (\ioe -> throwIO (ioeSetLocation ioe "copyFile"))
@@ -229,15 +229,15 @@ emptyToCurDir path = path
229229
-- | Like `copyFile`, but does not touch the target if source and destination
230230
-- are already byte-identical. This is recommended as it is useful for
231231
-- time-stamp based recompilation avoidance.
232-
copyFileChanged :: FilePath -> FilePath -> NoCallStackIO ()
232+
copyFileChanged :: FilePath -> FilePath -> IO ()
233233
copyFileChanged src dest = do
234234
equal <- filesEqual src dest
235235
unless equal $ copyFile src dest
236236

237237
-- | Checks if two files are byte-identical.
238238
-- Returns False if either of the files do not exist or if files
239239
-- are of different size.
240-
filesEqual :: FilePath -> FilePath -> NoCallStackIO Bool
240+
filesEqual :: FilePath -> FilePath -> IO Bool
241241
filesEqual f1 f2 = do
242242
ex1 <- doesFileExist f1
243243
ex2 <- doesFileExist f2

Cabal/Distribution/Compat/CreatePipe.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ createPipe = do
4444
hSetEncoding writeh localeEncoding
4545
return (readh, writeh)) `onException` (close readfd >> close writefd)
4646
where
47-
fdToHandle :: CInt -> IOMode -> NoCallStackIO Handle
47+
fdToHandle :: CInt -> IOMode -> IO Handle
4848
fdToHandle fd mode = do
4949
(fd', deviceType) <- mkFD fd mode (Just (Stream, 0, 0)) False False
5050
mkHandleFromFD fd' deviceType "" mode False Nothing

Cabal/Distribution/Compat/Environment.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import Foreign.C.Error (throwErrnoIfMinus1_)
3838
import System.Posix.Internals ( withFilePath )
3939
#endif /* mingw32_HOST_OS */
4040

41-
getEnvironment :: NoCallStackIO [(String, String)]
41+
getEnvironment :: IO [(String, String)]
4242
#ifdef mingw32_HOST_OS
4343
-- On Windows, the names of environment variables are case-insensitive, but are
4444
-- often given in mixed-case (e.g. "PATH" is "Path"), so we have to normalise

Cabal/Distribution/Compat/GetShortPathName.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ foreign import WINAPI unsafe "windows.h GetShortPathNameW"
4040
-- will always return the required buffer size for a
4141
-- specified lpszLongPath.
4242
--
43-
getShortPathName :: FilePath -> NoCallStackIO FilePath
43+
getShortPathName :: FilePath -> IO FilePath
4444
getShortPathName path =
4545
Win32.withTString path $ \c_path -> do
4646
c_len <- Win32.failIfZero "GetShortPathName #1 failed!" $
@@ -53,7 +53,7 @@ getShortPathName path =
5353

5454
#else
5555

56-
getShortPathName :: FilePath -> NoCallStackIO FilePath
56+
getShortPathName :: FilePath -> IO FilePath
5757
getShortPathName path = return path
5858

5959
#endif

Cabal/Distribution/Compat/Prelude.hs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ module Distribution.Compat.Prelude (
4444
IsString (..),
4545

4646
-- * Some types
47-
IO, NoCallStackIO,
4847
Map,
4948
Set,
5049
Identity (..),
@@ -106,7 +105,7 @@ module Distribution.Compat.Prelude (
106105
) where
107106
-- We also could hide few partial function
108107
import Prelude as BasePrelude hiding
109-
( IO, mapM, mapM_, sequence, null, length, foldr, any, all, head, tail, last, init
108+
( mapM, mapM_, sequence, null, length, foldr, any, all, head, tail, last, init
110109
-- partial functions
111110
, read
112111
, foldr1, foldl1
@@ -165,14 +164,8 @@ import Text.Read (readMaybe)
165164

166165
import qualified Text.PrettyPrint as Disp
167166

168-
import qualified Prelude as OrigPrelude
169-
import Distribution.Compat.Stack
170-
171167
import Distribution.Utils.Structured (Structured)
172168

173-
type IO a = WithCallStack (OrigPrelude.IO a)
174-
type NoCallStackIO a = OrigPrelude.IO a
175-
176169
-- | New name for 'Text.PrettyPrint.<>'
177170
(<<>>) :: Disp.Doc -> Disp.Doc -> Disp.Doc
178171
(<<>>) = (Disp.<>)

Cabal/Distribution/Compat/Time.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ instance Read ModTime where
7272
--
7373
-- This is a modified version of the code originally written for Shake by Neil
7474
-- Mitchell. See module Development.Shake.FileInfo.
75-
getModTime :: FilePath -> NoCallStackIO ModTime
75+
getModTime :: FilePath -> IO ModTime
7676

7777
#if defined mingw32_HOST_OS
7878

@@ -110,7 +110,7 @@ getModTime path = allocaBytes size_WIN32_FILE_ATTRIBUTE_DATA $ \info -> do
110110
foreign import CALLCONV "windows.h GetFileAttributesExW"
111111
c_getFileAttributesEx :: LPCTSTR -> Int32 -> LPVOID -> Prelude.IO BOOL
112112

113-
getFileAttributesEx :: String -> LPVOID -> NoCallStackIO BOOL
113+
getFileAttributesEx :: String -> LPVOID -> IO BOOL
114114
getFileAttributesEx path lpFileInformation =
115115
withTString path $ \c_path ->
116116
c_getFileAttributesEx c_path getFileExInfoStandard lpFileInformation
@@ -154,14 +154,14 @@ posixTimeToModTime p = ModTime $ (ceiling $ p * 1e7) -- 100 ns precision
154154
+ (secToUnixEpoch * windowsTick)
155155

156156
-- | Return age of given file in days.
157-
getFileAge :: FilePath -> NoCallStackIO Double
157+
getFileAge :: FilePath -> IO Double
158158
getFileAge file = do
159159
t0 <- getModificationTime file
160160
t1 <- getCurrentTime
161161
return $ realToFrac (t1 `diffUTCTime` t0) / realToFrac posixDayLength
162162

163163
-- | Return the current time as 'ModTime'.
164-
getCurTime :: NoCallStackIO ModTime
164+
getCurTime :: IO ModTime
165165
getCurTime = posixTimeToModTime `fmap` getPOSIXTime -- Uses 'gettimeofday'.
166166

167167
-- | Based on code written by Neil Mitchell for Shake. See

Cabal/Distribution/PackageDescription/Check.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,7 @@ checkDevelopmentOnlyFlags pkg =
18861886
-- | Sanity check things that requires IO. It looks at the files in the
18871887
-- package and expects to find the package unpacked in at the given file path.
18881888
--
1889-
checkPackageFiles :: Verbosity -> PackageDescription -> FilePath -> NoCallStackIO [PackageCheck]
1889+
checkPackageFiles :: Verbosity -> PackageDescription -> FilePath -> IO [PackageCheck]
18901890
checkPackageFiles verbosity pkg root = do
18911891
contentChecks <- checkPackageContent checkFilesIO pkg
18921892
preDistributionChecks <- checkPackageFilesPreDistribution verbosity pkg root
@@ -2202,7 +2202,7 @@ checkTarPath path
22022202
-- check these on the server; these checks only make sense in the development
22032203
-- and package-creation environment. Hence we can use IO, rather than needing
22042204
-- to pass a 'CheckPackageContentOps' dictionary around.
2205-
checkPackageFilesPreDistribution :: Verbosity -> PackageDescription -> FilePath -> NoCallStackIO [PackageCheck]
2205+
checkPackageFilesPreDistribution :: Verbosity -> PackageDescription -> FilePath -> IO [PackageCheck]
22062206
-- Note: this really shouldn't return any 'Inexcusable' warnings,
22072207
-- because that will make us say that Hackage would reject the package.
22082208
-- But, because Hackage doesn't run these tests, that will be a lie!
@@ -2212,7 +2212,7 @@ checkPackageFilesPreDistribution = checkGlobFiles
22122212
checkGlobFiles :: Verbosity
22132213
-> PackageDescription
22142214
-> FilePath
2215-
-> NoCallStackIO [PackageCheck]
2215+
-> IO [PackageCheck]
22162216
checkGlobFiles verbosity pkg root =
22172217
fmap concat $ for allGlobs $ \(field, dir, glob) ->
22182218
-- Note: we just skip over parse errors here; they're reported elsewhere.

Cabal/Distribution/PackageDescription/PrettyPrint.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import Text.PrettyPrint (Doc, char, hsep, parens, text, (<+>))
5757
import qualified Data.ByteString.Lazy.Char8 as BS.Char8
5858

5959
-- | Writes a .cabal file from a generic package description
60-
writeGenericPackageDescription :: FilePath -> GenericPackageDescription -> NoCallStackIO ()
60+
writeGenericPackageDescription :: FilePath -> GenericPackageDescription -> IO ()
6161
writeGenericPackageDescription fpath pkg = writeUTF8File fpath (showGenericPackageDescription pkg)
6262

6363
-- | Writes a generic package description to a string
@@ -192,7 +192,7 @@ ppIfCondition :: Condition ConfVar -> [PrettyField ()] -> PrettyField ()
192192
ppIfCondition c = PrettySection () "if" [ppCondition c]
193193

194194
-- | @since 2.0.0.2
195-
writePackageDescription :: FilePath -> PackageDescription -> NoCallStackIO ()
195+
writePackageDescription :: FilePath -> PackageDescription -> IO ()
196196
writePackageDescription fpath pkg = writeUTF8File fpath (showPackageDescription pkg)
197197

198198
--TODO: make this use section syntax
@@ -225,7 +225,7 @@ pdToGpd pd = GenericPackageDescription
225225
mkCondTree' f x = (f x, CondNode x [] [])
226226

227227
-- | @since 2.0.0.2
228-
writeHookedBuildInfo :: FilePath -> HookedBuildInfo -> NoCallStackIO ()
228+
writeHookedBuildInfo :: FilePath -> HookedBuildInfo -> IO ()
229229
writeHookedBuildInfo fpath = writeFileAtomic fpath . BS.Char8.pack
230230
. showHookedBuildInfo
231231

Cabal/Distribution/PackageDescription/Quirks.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ patches = Map.fromList
256256
mk a b c d = ((a, b), (c, d))
257257

258258
-- | Helper to create entries in patches
259-
_makePatchKey :: FilePath -> (BS.ByteString -> BS.ByteString) -> NoCallStackIO ()
259+
_makePatchKey :: FilePath -> (BS.ByteString -> BS.ByteString) -> IO ()
260260
_makePatchKey fp transform = do
261261
contents <- BS.readFile fp
262262
let output = transform contents

Cabal/Distribution/Simple.hs

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ clean pkg_descr flags = do
606606
traverse_ (writePersistBuildConfig distPref) maybeConfig
607607

608608
where
609-
removeFileOrDirectory :: FilePath -> NoCallStackIO ()
609+
removeFileOrDirectory :: FilePath -> IO ()
610610
removeFileOrDirectory fname = do
611611
isDir <- doesDirectoryExist fname
612612
isFile <- doesFileExist fname
@@ -740,11 +740,13 @@ runConfigureScript verbosity backwardsCompatHack flags lbi = do
740740
let configureFile' = intercalate "/" $ splitDirectories configureFile
741741
for_ badAutoconfCharacters $ \(c, cname) ->
742742
when (c `elem` dropDrive configureFile') $
743-
warn verbosity $
744-
"The path to the './configure' script, '" ++ configureFile'
745-
++ "', contains the character '" ++ [c] ++ "' (" ++ cname ++ ")."
746-
++ " This may cause the script to fail with an obscure error, or for"
747-
++ " building the package to fail later."
743+
warn verbosity $ concat
744+
[ "The path to the './configure' script, '", configureFile'
745+
, "', contains the character '", [c], "' (", cname, ")."
746+
, " This may cause the script to fail with an obscure error, or for"
747+
, " building the package to fail later."
748+
]
749+
748750
let extraPath = fromNubList $ configProgramPathExtra flags
749751
let cflagsEnv = maybe (unwords ccFlags) (++ (" " ++ unwords ccFlags))
750752
$ lookup "CFLAGS" env
@@ -766,40 +768,40 @@ runConfigureScript verbosity backwardsCompatHack flags lbi = do
766768
(programInvocation (sh {programOverrideEnv = overEnv}) args')
767769
{ progInvokeCwd = Just (buildDir lbi) }
768770
Nothing -> die' verbosity notFoundMsg
769-
770771
where
771772
args = configureArgs backwardsCompatHack flags
772773

773-
badAutoconfCharacters =
774-
[ (' ', "space")
775-
, ('\t', "tab")
776-
, ('\n', "newline")
777-
, ('\0', "null")
778-
, ('"', "double quote")
779-
, ('#', "hash")
780-
, ('$', "dollar sign")
781-
, ('&', "ampersand")
782-
, ('\'', "single quote")
783-
, ('(', "left bracket")
784-
, (')', "right bracket")
785-
, ('*', "star")
786-
, (';', "semicolon")
787-
, ('<', "less-than sign")
788-
, ('=', "equals sign")
789-
, ('>', "greater-than sign")
790-
, ('?', "question mark")
791-
, ('[', "left square bracket")
792-
, ('\\', "backslash")
793-
, ('`', "backtick")
794-
, ('|', "pipe")
795-
]
796-
797774
notFoundMsg = "The package has a './configure' script. "
798775
++ "If you are on Windows, This requires a "
799776
++ "Unix compatibility toolchain such as MinGW+MSYS or Cygwin. "
800777
++ "If you are not on Windows, ensure that an 'sh' command "
801778
++ "is discoverable in your path."
802779

780+
badAutoconfCharacters :: [(Char, String)]
781+
badAutoconfCharacters =
782+
[ (' ', "space")
783+
, ('\t', "tab")
784+
, ('\n', "newline")
785+
, ('\0', "null")
786+
, ('"', "double quote")
787+
, ('#', "hash")
788+
, ('$', "dollar sign")
789+
, ('&', "ampersand")
790+
, ('\'', "single quote")
791+
, ('(', "left bracket")
792+
, (')', "right bracket")
793+
, ('*', "star")
794+
, (';', "semicolon")
795+
, ('<', "less-than sign")
796+
, ('=', "equals sign")
797+
, ('>', "greater-than sign")
798+
, ('?', "question mark")
799+
, ('[', "left square bracket")
800+
, ('\\', "backslash")
801+
, ('`', "backtick")
802+
, ('|', "pipe")
803+
]
804+
803805
getHookedBuildInfo :: Verbosity -> FilePath -> IO HookedBuildInfo
804806
getHookedBuildInfo verbosity build_dir = do
805807
maybe_infoFile <- findHookedPackageDesc verbosity build_dir

Cabal/Distribution/Simple/BuildTarget.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ readBuildTargets verbosity pkg targetStrs = do
154154

155155
return btargets
156156

157-
checkTargetExistsAsFile :: UserBuildTarget -> NoCallStackIO (UserBuildTarget, Bool)
157+
checkTargetExistsAsFile :: UserBuildTarget -> IO (UserBuildTarget, Bool)
158158
checkTargetExistsAsFile t = do
159159
fexists <- existsAsFile (fileComponentOfTarget t)
160160
return (t, fexists)

Cabal/Distribution/Simple/Compiler.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,10 @@ registrationPackageDB dbs = case safeLast dbs of
206206
-- | Make package paths absolute
207207

208208

209-
absolutePackageDBPaths :: PackageDBStack -> NoCallStackIO PackageDBStack
209+
absolutePackageDBPaths :: PackageDBStack -> IO PackageDBStack
210210
absolutePackageDBPaths = traverse absolutePackageDBPath
211211

212-
absolutePackageDBPath :: PackageDB -> NoCallStackIO PackageDB
212+
absolutePackageDBPath :: PackageDB -> IO PackageDB
213213
absolutePackageDBPath GlobalPackageDB = return GlobalPackageDB
214214
absolutePackageDBPath UserPackageDB = return UserPackageDB
215215
absolutePackageDBPath (SpecificPackageDB db) =

Cabal/Distribution/Simple/Configure.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ maybeGetPersistBuildConfig =
253253
-- 'localBuildInfoFile'.
254254
writePersistBuildConfig :: FilePath -- ^ The @dist@ directory path.
255255
-> LocalBuildInfo -- ^ The 'LocalBuildInfo' to write.
256-
-> NoCallStackIO ()
256+
-> IO ()
257257
writePersistBuildConfig distPref lbi = do
258258
createDirectoryIfMissing False distPref
259259
writeFileAtomic (localBuildInfoFile distPref) $
@@ -298,7 +298,7 @@ showHeader pkgId = BLC8.unwords
298298

299299
-- | Check that localBuildInfoFile is up-to-date with respect to the
300300
-- .cabal file.
301-
checkPersistBuildConfigOutdated :: FilePath -> FilePath -> NoCallStackIO Bool
301+
checkPersistBuildConfigOutdated :: FilePath -> FilePath -> IO Bool
302302
checkPersistBuildConfigOutdated distPref pkg_descr_file =
303303
pkg_descr_file `moreRecentFile` localBuildInfoFile distPref
304304

@@ -316,7 +316,7 @@ localBuildInfoFile distPref = distPref </> "setup-config"
316316
-- \"CABAL_BUILDDIR\" environment variable, or the default prefix.
317317
findDistPref :: FilePath -- ^ default \"dist\" prefix
318318
-> Setup.Flag FilePath -- ^ override \"dist\" prefix
319-
-> NoCallStackIO FilePath
319+
-> IO FilePath
320320
findDistPref defDistPref overrideDistPref = do
321321
envDistPref <- liftM parseEnvDistPref (lookupEnv "CABAL_BUILDDIR")
322322
return $ fromFlagOrDefault defDistPref (mappend envDistPref overrideDistPref)
@@ -333,7 +333,7 @@ findDistPref defDistPref overrideDistPref = do
333333
-- set. (The @*DistPref@ flags are always set to a definite value before
334334
-- invoking 'UserHooks'.)
335335
findDistPrefOrDefault :: Setup.Flag FilePath -- ^ override \"dist\" prefix
336-
-> NoCallStackIO FilePath
336+
-> IO FilePath
337337
findDistPrefOrDefault = findDistPref defaultDistPref
338338

339339
-- |Perform the \"@.\/setup configure@\" action.
@@ -1660,7 +1660,7 @@ configurePkgconfigPackages verbosity pkg_descr progdb enabled
16601660
addPkgConfigBIBench = addPkgConfigBI benchmarkBuildInfo $
16611661
\bench bi -> bench { benchmarkBuildInfo = bi }
16621662

1663-
pkgconfigBuildInfo :: [PkgconfigDependency] -> NoCallStackIO BuildInfo
1663+
pkgconfigBuildInfo :: [PkgconfigDependency] -> IO BuildInfo
16641664
pkgconfigBuildInfo [] = return mempty
16651665
pkgconfigBuildInfo pkgdeps = do
16661666
let pkgs = nub [ prettyShow pkg | PkgconfigDependency pkg _ <- pkgdeps ]

0 commit comments

Comments
 (0)