Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
81c2d4f7
Commit
81c2d4f7
authored
Sep 25, 2016
by
Herbert Valerio Riedel
🕺
Browse files
Move `readMaybe` to Client.Prelude and remove dupes
parent
70e2f902
Changes
5
Hide whitespace changes
Inline
Side-by-side
cabal-install/Distribution/Client/Compat/Prelude.hs
View file @
81c2d4f7
{-# LANGUAGE CPP #-}
-- | This module does two things:
--
-- * Acts as a compatiblity layer, like @base-compat@.
...
...
@@ -10,7 +12,21 @@
module
Distribution.Client.Compat.Prelude
(
module
Distribution
.
Compat
.
Prelude
,
Prelude
.
IO
,
readMaybe
)
where
import
Prelude
(
IO
)
import
Distribution.Compat.Prelude
hiding
(
IO
)
#
if
MIN_VERSION_base
(
4
,
6
,
0
)
import
Text.Read
(
readMaybe
)
#
endif
#
if
!
MIN_VERSION_base
(
4
,
6
,
0
)
-- | An implementation of readMaybe, for compatability with older base versions.
readMaybe
::
Read
a
=>
String
->
Maybe
a
readMaybe
s
=
case
reads
s
of
[(
x
,
""
)]
->
Just
x
_
->
Nothing
#
endif
cabal-install/Distribution/Client/HttpUtils.hs
View file @
81c2d4f7
...
...
@@ -41,7 +41,7 @@ import Distribution.Simple.Utils
,
copyFileVerbose
,
withTempFile
,
rawSystemStdInOut
,
toUTF8
,
fromUTF8
,
normaliseLineEndings
)
import
Distribution.Client.Utils
(
readMaybe
,
withTempFileName
)
(
withTempFileName
)
import
Distribution.Client.Types
(
RemoteRepo
(
..
)
)
import
Distribution.System
...
...
cabal-install/Distribution/Client/Init.hs
View file @
81c2d4f7
...
...
@@ -603,11 +603,6 @@ promptList' displayItem numChoices choices def other = do
=
return
.
Right
$
choices
!!
(
n
-
1
)
|
otherwise
=
Left
`
fmap
`
promptStr
"Please specify"
Nothing
readMaybe
::
(
Read
a
)
=>
String
->
Maybe
a
readMaybe
s
=
case
reads
s
of
[(
a
,
""
)]
->
Just
a
_
->
Nothing
---------------------------------------------------------------------------
-- File generation ------------------------------------------------------
---------------------------------------------------------------------------
...
...
cabal-install/Distribution/Client/Setup.hs
View file @
81c2d4f7
...
...
@@ -1772,9 +1772,6 @@ initCommand = CommandUI {
,
optionVerbosity
IT
.
initVerbosity
(
\
v
flags
->
flags
{
IT
.
initVerbosity
=
v
})
]
}
where
readMaybe
s
=
case
reads
s
of
[(
x
,
""
)]
->
Just
x
_
->
Nothing
-- ------------------------------------------------------------
-- * SDist flags
...
...
cabal-install/Distribution/Client/Utils.hs
View file @
81c2d4f7
...
...
@@ -31,10 +31,6 @@ import qualified Data.ByteString.Lazy as BS
import
Data.Bits
(
(
.|.
),
shiftL
,
shiftR
)
import
System.FilePath
#
if
MIN_VERSION_base
(
4
,
6
,
0
)
import
Text.Read
(
readMaybe
)
#
endif
import
Data.List
(
groupBy
)
import
Data.Word
...
...
@@ -93,14 +89,6 @@ duplicatesBy cmp = filter moreThanOne . groupBy eq . sortBy cmp
moreThanOne
(
_
:
_
:
_
)
=
True
moreThanOne
_
=
False
#
if
!
MIN_VERSION_base
(
4
,
6
,
0
)
-- | An implementation of readMaybe, for compatability with older base versions.
readMaybe
::
Read
a
=>
String
->
Maybe
a
readMaybe
s
=
case
reads
s
of
[(
x
,
""
)]
->
Just
x
_
->
Nothing
#
endif
-- | Like 'removeFile', but does not throw an exception when the file does not
-- exist.
removeExistingFile
::
FilePath
->
IO
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment