Skip to content

Commit a38cc73

Browse files
committed
Improve the docs for stripExtension
1 parent 802046a commit a38cc73

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

System/FilePath/Internal.hs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,12 @@ hasExtension :: FilePath -> Bool
312312
hasExtension = any isExtSeparator . takeFileName
313313

314314

315-
-- | Drop the given extension from a FilePath, and the \".\" preceding it.
315+
-- | Drop the given extension from a FilePath, and the @\".\"@ preceding it.
316+
-- Returns 'Nothing' if the FilePath does not have the given extension, or
317+
-- 'Just' and the part before the extension if it does.
316318
--
317-
-- It returns Nothing if the FilePath does not have the extension given, or
318-
-- Just the part before the extension, if it does.
319-
--
320-
-- It is safer to use this function than System.FilePath.dropExtensions,
321-
-- because FilePath might be something like 'file.name.ext1.ext2', where we
322-
-- want to only drop the 'ext1.ext2' part, but keep the full 'file.name' part.
319+
-- This function can be more predictable than 'dropExtensions', especially if the filename
320+
-- might itself contain @.@ characters.
323321
--
324322
-- > stripExtension "hs.o" "foo.x.hs.o" == Just "foo.x"
325323
-- > stripExtension "hi.o" "foo.x.hs.o" == Nothing

0 commit comments

Comments
 (0)