Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
filepath
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Glasgow Haskell Compiler
Packages
filepath
Commits
486373cb
Commit
486373cb
authored
11 years ago
by
Herbert Valerio Riedel
Browse files
Options
Downloads
Patches
Plain Diff
Minor refactorings as suggested by hlint
Signed-off-by:
Herbert Valerio Riedel
<
hvr@gnu.org
>
parent
78748dc2
No related branches found
Branches containing commit
Tags
filepath-1.3.0.2-release
ghc-7.8.1-release
ghc-7.8.2-release
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
System/FilePath/Internal.hs
+7
-9
7 additions, 9 deletions
System/FilePath/Internal.hs
with
7 additions
and
9 deletions
System/FilePath/Internal.hs
+
7
−
9
View file @
486373cb
...
@@ -87,7 +87,7 @@ module System.FilePath.MODULE_NAME
...
@@ -87,7 +87,7 @@ module System.FilePath.MODULE_NAME
)
)
where
where
import
Data.Char
(
toLower
,
toUpper
)
import
Data.Char
(
toLower
,
toUpper
,
isAsciiLower
,
isAsciiUpper
)
import
Data.Maybe
(
isJust
,
fromJust
)
import
Data.Maybe
(
isJust
,
fromJust
)
import
Data.List
(
isPrefixOf
)
import
Data.List
(
isPrefixOf
)
...
@@ -304,7 +304,7 @@ takeExtensions = snd . splitExtensions
...
@@ -304,7 +304,7 @@ takeExtensions = snd . splitExtensions
-- | Is the given character a valid drive letter?
-- | Is the given character a valid drive letter?
-- only a-z and A-Z are letters, not isAlpha which is more unicodey
-- only a-z and A-Z are letters, not isAlpha which is more unicodey
isLetter
::
Char
->
Bool
isLetter
::
Char
->
Bool
isLetter
x
=
(
x
>=
'a'
&&
x
<=
'z'
)
||
(
x
>=
'A'
&&
x
<=
'Z'
)
isLetter
x
=
isAsciiLower
x
||
isAsciiUpper
x
-- | Split a path into a drive and a path.
-- | Split a path into a drive and a path.
...
@@ -536,9 +536,7 @@ dropTrailingPathSeparator x =
...
@@ -536,9 +536,7 @@ dropTrailingPathSeparator x =
-- > Windows: takeDirectory "foo\\bar\\\\" == "foo\\bar"
-- > Windows: takeDirectory "foo\\bar\\\\" == "foo\\bar"
-- > Windows: takeDirectory "C:\\" == "C:\\"
-- > Windows: takeDirectory "C:\\" == "C:\\"
takeDirectory
::
FilePath
->
FilePath
takeDirectory
::
FilePath
->
FilePath
takeDirectory
x
=
if
isDrive
file
then
file
takeDirectory
x
=
if
isDrive
file
||
(
null
res
&&
not
(
null
file
))
then
file
else
res
else
if
null
res
&&
not
(
null
file
)
then
file
else
res
where
where
res
=
reverse
$
dropWhile
isPathSeparator
$
reverse
file
res
=
reverse
$
dropWhile
isPathSeparator
$
reverse
file
file
=
dropFileName
x
file
=
dropFileName
x
...
@@ -593,7 +591,7 @@ splitPath x = [drive | drive /= ""] ++ f path
...
@@ -593,7 +591,7 @@ splitPath x = [drive | drive /= ""] ++ f path
f
y
=
(
a
++
c
)
:
f
d
f
y
=
(
a
++
c
)
:
f
d
where
where
(
a
,
b
)
=
break
isPathSeparator
y
(
a
,
b
)
=
break
isPathSeparator
y
(
c
,
d
)
=
break
(
not
.
isPathSeparator
)
b
(
c
,
d
)
=
span
isPathSeparator
b
-- | Just as 'splitPath', but don't add the trailing slashes to each element.
-- | Just as 'splitPath', but don't add the trailing slashes to each element.
--
--
...
@@ -608,7 +606,7 @@ splitDirectories path =
...
@@ -608,7 +606,7 @@ splitDirectories path =
where
where
pathComponents
=
splitPath
path
pathComponents
=
splitPath
path
f
xs
=
map
g
xs
f
=
map
g
g
x
=
if
null
res
then
x
else
res
g
x
=
if
null
res
then
x
else
res
where
res
=
takeWhile
(
not
.
isPathSeparator
)
x
where
res
=
takeWhile
(
not
.
isPathSeparator
)
x
...
@@ -621,7 +619,7 @@ splitDirectories path =
...
@@ -621,7 +619,7 @@ splitDirectories path =
-- Note that this definition on c:\\c:\\, join then split will give c:\\.
-- Note that this definition on c:\\c:\\, join then split will give c:\\.
joinPath
::
[
FilePath
]
->
FilePath
joinPath
::
[
FilePath
]
->
FilePath
joinPath
x
=
foldr
combine
""
x
joinPath
=
foldr
combine
""
...
@@ -799,7 +797,7 @@ makeValid path = joinDrive drv $ validElements $ validChars pth
...
@@ -799,7 +797,7 @@ makeValid path = joinDrive drv $ validElements $ validChars pth
where
where
(
drv
,
pth
)
=
splitDrive
path
(
drv
,
pth
)
=
splitDrive
path
validChars
x
=
map
f
x
validChars
=
map
f
f
x
|
x
`
elem
`
badCharacters
=
'_'
f
x
|
x
`
elem
`
badCharacters
=
'_'
|
otherwise
=
x
|
otherwise
=
x
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment