Commit d4a47fb1 authored by Neil Mitchell's avatar Neil Mitchell
Browse files

#9, add -<.> as an alias for replaceExtension

parent 6854fc27
......@@ -84,7 +84,7 @@ qualify pw str
where
prelude = ["elem","uncurry","snd","fst","not","null","if","then","else"
,"True","False","concat","isPrefixOf","isSuffixOf"]
fpops = ["</>","<.>"]
fpops = ["</>","<.>","-<.>"]
---------------------------------------------------------------------
......
......@@ -58,7 +58,7 @@ module System.FilePath.MODULE_NAME
-- * Extension methods
splitExtension,
takeExtension, replaceExtension, dropExtension, addExtension, hasExtension, (<.>),
takeExtension, replaceExtension, (-<.>), dropExtension, addExtension, hasExtension, (<.>),
splitExtensions, dropExtensions, takeExtensions,
-- * Drive methods
......@@ -92,7 +92,7 @@ import Data.Maybe(isJust, fromJust)
import System.Environment(getEnv)
infixr 7 <.>
infixr 7 <.>, -<.>
infixr 5 </>
......@@ -228,6 +228,12 @@ splitExtension x = case nameDot of
takeExtension :: FilePath -> String
takeExtension = snd . splitExtension
-- | Remove the current extension and add another, an alias for 'replaceExtension'.
--
-- > "foo.o" -<.> "c" == "foo.c"
(-<.>) :: FilePath -> String -> FilePath
(-<.>) = replaceExtension
-- | Set the extension of a file, overwriting one if already present.
--
-- > replaceExtension "file.txt" ".bob" == "file.bob"
......
......@@ -6,6 +6,8 @@ _Note: below all `FilePath` values are unquoted, so `\\` really means two backsl
* Bundled with GHC 7.10.1
* New function: Add `-<.>` as an alias for `replaceExtension`.
* Semantic change: `joinDrive /foo bar` now returns `/foo/bar`, instead of `/foobar`
* Semantic change: on Windows, `splitSearchPath File1;\"File 2\"` now returns `[File1,File2]` instead of `[File1,\"File2\"]`
......
......@@ -52,6 +52,8 @@ tests =
,("W.takeExtension (W.addExtension x \"ext\") == \".ext\"", test $ \(QFilePathValidW x) -> W.takeExtension (W.addExtension x "ext") == ".ext")
,("P.takeExtension (P.replaceExtension x \"ext\") == \".ext\"", test $ \(QFilePathValidP x) -> P.takeExtension (P.replaceExtension x "ext") == ".ext")
,("W.takeExtension (W.replaceExtension x \"ext\") == \".ext\"", test $ \(QFilePathValidW x) -> W.takeExtension (W.replaceExtension x "ext") == ".ext")
,("\"foo.o\" P.-<.> \"c\" == \"foo.c\"", test $ "foo.o" P.-<.> "c" == "foo.c")
,("\"foo.o\" W.-<.> \"c\" == \"foo.c\"", test $ "foo.o" W.-<.> "c" == "foo.c")
,("P.replaceExtension \"file.txt\" \".bob\" == \"file.bob\"", test $ P.replaceExtension "file.txt" ".bob" == "file.bob")
,("W.replaceExtension \"file.txt\" \".bob\" == \"file.bob\"", test $ W.replaceExtension "file.txt" ".bob" == "file.bob")
,("P.replaceExtension \"file.txt\" \"bob\" == \"file.bob\"", test $ P.replaceExtension "file.txt" "bob" == "file.bob")
......
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