path-extensions 0.1.0.1 → 0.1.1.0
raw patch · 4 files changed
+141/−31 lines, 4 files
Files
- ChangeLog.md +5/−0
- LICENSE +16/−27
- path-extensions.cabal +3/−2
- src/Path/Extensions.hs +117/−2
ChangeLog.md view
@@ -1,5 +1,10 @@ # Changelog for path-extensions +## v0.1.1.0++* Add docx, odt, rtf, sh, tex, txt and wiki extensions.+* Fix error with gif and hs extensions.+ ## v0.1.0.0 * Add docstrings.
LICENSE view
@@ -1,30 +1,19 @@-Copyright Daniel Firth (c) 2020--All rights reserved.--Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions are met:-- * Redistributions of source code must retain the above copyright- notice, this list of conditions and the following disclaimer.+Copyright (c) 2020 Daniel Firth - * Redistributions in binary form must reproduce the above- copyright notice, this list of conditions and the following- disclaimer in the documentation and/or other materials provided- with the distribution.+Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions: - * Neither the name of Author name here nor the names of other- contributors may be used to endorse or promote products derived- from this software without specific prior written permission.+The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.
path-extensions.cabal view
@@ -5,14 +5,14 @@ -- see: https://github.com/sol/hpack name: path-extensions-version: 0.1.0.1+version: 0.1.1.0 synopsis: Enumeration of common filetype extensions for use with the path library. description: Enumeration of common filetype extensions for use with the path library, add variants for adding an extension to a path and with variants for replacing an existing extension. category: Filesystem author: Daniel Firth maintainer: dan.firth@homotopic.tech copyright: 2020 Daniel Firth-license: BSD3+license: MIT license-file: LICENSE build-type: Simple extra-source-files:@@ -30,6 +30,7 @@ Paths_path_extensions hs-source-dirs: src+ ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints build-depends: base >=4.7 && <5 , exceptions
src/Path/Extensions.hs view
@@ -1,8 +1,19 @@+{- |+ Module : Path.Extensions+ Copyright : Copyright (C) 2020 Daniel Firth+ Maintainer : Daniel Firth <dan.firth@homotopic.tech+ License : MIT+ Stability : provisional++Enumeration of file extensions for use with the Path library.+-}+ module Path.Extensions ( -- * Raw Extension Strings cExtension , cppExtension , cssExtension+, docxExtension , gifExtension , hsExtension , htmlExtension@@ -12,17 +23,24 @@ , mp3Extension , mp4Extension , oExtension+, odtExtension , pdfExtension , phpExtension , pngExtension , pyExtension+, rtfExtension+, shExtension , svgExtension+, texExtension+, txtExtension , xmlExtension+, wikiExtension -- * Add Extensions , addCExtension , addCppExtension , addCssExtension+, addDocxExtension , addGifExtension , addHsExtension , addHtmlExtension@@ -32,17 +50,24 @@ , addMp3Extension , addMp4Extension , addOExtension+, addOdtExtension , addPdfExtension , addPhpExtension , addPngExtension , addPyExtension+, addRtfExtension+, addShExtension , addSvgExtension+, addTexExtension+, addTxtExtension , addXmlExtension+, addWikiExtension -- * Replace Extensions , withCExtension , withCppExtension , withCssExtension+, withDocxExtension , withGifExtension , withHsExtension , withHtmlExtension@@ -52,12 +77,18 @@ , withMp3Extension , withMp4Extension , withOExtension+, withOdtExtension , withPdfExtension , withPhpExtension , withPngExtension , withPyExtension+, withRtfExtension+, withShExtension , withSvgExtension+, withTexExtension+, withTxtExtension , withXmlExtension+, withWikiExtension ) where import Control.Monad.Catch@@ -75,6 +106,10 @@ cssExtension :: String cssExtension = ".css" +-- | The string ".docx"+docxExtension :: String+docxExtension = ".docx"+ -- | The string ".gif". gifExtension :: String gifExtension = ".gif"@@ -111,6 +146,10 @@ oExtension :: String oExtension = ".o" +-- | The string ".odt"+odtExtension :: String+odtExtension = ".odt"+ -- | The string ".pdf". pdfExtension :: String pdfExtension = ".pdf"@@ -127,14 +166,34 @@ pyExtension :: String pyExtension = ".py" +-- | The string ".rtf".+rtfExtension :: String+rtfExtension = ".rtf"++-- | The string ".sh"+shExtension :: String+shExtension = ".sh"+ -- | The string ".svg" svgExtension :: String svgExtension = ".svg" +-- | The string ".tex"+texExtension :: String+texExtension = ".tex"++-- | The string ".txt"+txtExtension :: String+txtExtension = ".txt"+ -- | The string ".xml". xmlExtension :: String xmlExtension = ".xml" +-- | The string ".wiki"+wikiExtension :: String+wikiExtension = ".wiki"+ -- | Add a ".c" extension to the end of a `File`. addCExtension :: MonadThrow m => Path b File -> m (Path b File) addCExtension = addExtension cExtension@@ -147,13 +206,17 @@ addCssExtension :: MonadThrow m => Path b File -> m (Path b File) addCssExtension = addExtension cssExtension +-- | Add a ".docx" extension to the end of a `File`.+addDocxExtension :: MonadThrow m => Path b File -> m (Path b File)+addDocxExtension = addExtension docxExtension+ -- | Add a ".gif" extension to the end of a `File`. addGifExtension :: MonadThrow m => Path b File -> m (Path b File)-addGifExtension = addExtension cExtension+addGifExtension = addExtension gifExtension -- | Add a ".hs" extension to the end of a `File`. addHsExtension :: MonadThrow m => Path b File -> m (Path b File)-addHsExtension = addExtension gifExtension+addHsExtension = addExtension hsExtension -- | Add a ".html" extension to the end of a `File`. addHtmlExtension :: MonadThrow m => Path b File -> m (Path b File)@@ -183,6 +246,10 @@ addOExtension :: MonadThrow m => Path b File -> m (Path b File) addOExtension = addExtension oExtension +-- | Add a ".odt" extension to the end of a `File`.+addOdtExtension :: MonadThrow m => Path b File -> m (Path b File)+addOdtExtension = addExtension odtExtension+ -- | Add a ".pdf" extension to the end of a `File`. addPdfExtension :: MonadThrow m => Path b File -> m (Path b File) addPdfExtension = addExtension pdfExtension@@ -199,14 +266,34 @@ addPyExtension :: MonadThrow m => Path b File -> m (Path b File) addPyExtension = addExtension pyExtension +-- | Add a ".rtf" extension to the end of a `File`.+addRtfExtension :: MonadThrow m => Path b File -> m (Path b File)+addRtfExtension = addExtension rtfExtension++-- | Add a ".sh" extension to the end of a `File`.+addShExtension :: MonadThrow m => Path b File -> m (Path b File)+addShExtension = addExtension shExtension+ -- | Add a ".svg" extension to the end of a `File`. addSvgExtension :: MonadThrow m => Path b File -> m (Path b File) addSvgExtension = addExtension svgExtension +-- | Add a ".tex" extension to the end of a `File`.+addTexExtension :: MonadThrow m => Path b File -> m (Path b File)+addTexExtension = addExtension texExtension++-- | Add a ".txt" extension to the end of a `File`.+addTxtExtension :: MonadThrow m => Path b File -> m (Path b File)+addTxtExtension = addExtension txtExtension+ -- | Add a ".xml" extension to the end of a `File`. addXmlExtension :: MonadThrow m => Path b File -> m (Path b File) addXmlExtension = addExtension xmlExtension +-- | Add a ".wiki" extension to the end of a `File`.+addWikiExtension :: MonadThrow m => Path b File -> m (Path b File)+addWikiExtension = addExtension wikiExtension+ -- | Replace the current extension of a `File` with a ".c" extension. withCExtension :: MonadThrow m => Path b File -> m (Path b File) withCExtension = replaceExtension cExtension@@ -219,6 +306,10 @@ withCssExtension :: MonadThrow m => Path b File -> m (Path b File) withCssExtension = replaceExtension cssExtension +-- | Replace the current extension of a `File` with a ".docx" extension.+withDocxExtension :: MonadThrow m => Path b File -> m (Path b File)+withDocxExtension = replaceExtension docxExtension+ -- | Replace the current extension of a `File` with a ".gif" extension. withGifExtension :: MonadThrow m => Path b File -> m (Path b File) withGifExtension = replaceExtension gifExtension@@ -255,6 +346,10 @@ withOExtension :: MonadThrow m => Path b File -> m (Path b File) withOExtension = replaceExtension oExtension +-- | Replace the current extension of a `File` with a ".odt" extension.+withOdtExtension :: MonadThrow m => Path b File -> m (Path b File)+withOdtExtension = replaceExtension odtExtension+ -- | Replace the current extension of a `File` with a ".pdf" extension. withPdfExtension :: MonadThrow m => Path b File -> m (Path b File) withPdfExtension = replaceExtension pdfExtension@@ -271,10 +366,30 @@ withPyExtension :: MonadThrow m => Path b File -> m (Path b File) withPyExtension = replaceExtension pyExtension +-- | Replace the current extension of a `File` with a ".rtf" extension.+withRtfExtension :: MonadThrow m => Path b File -> m (Path b File)+withRtfExtension = replaceExtension rtfExtension++-- | Replace the current extension of a `File` with a ".sh" extension.+withShExtension :: MonadThrow m => Path b File -> m (Path b File)+withShExtension = replaceExtension shExtension+ -- | Replace the current extension of a `File` with a ".svg" extension. withSvgExtension :: MonadThrow m => Path b File -> m (Path b File) withSvgExtension = replaceExtension svgExtension +-- | Replace the current extension of a `File` with a ".tex" extension.+withTexExtension :: MonadThrow m => Path b File -> m (Path b File)+withTexExtension = replaceExtension texExtension++-- | Replace the current extension of a `File` with a ".txt" extension.+withTxtExtension :: MonadThrow m => Path b File -> m (Path b File)+withTxtExtension = replaceExtension txtExtension+ -- | Replace the current extension of a `File` with a ".xml" extension. withXmlExtension :: MonadThrow m => Path b File -> m (Path b File) withXmlExtension = replaceExtension xmlExtension++-- | Replace the current extension of a `File` with a ".wiki" extension.+withWikiExtension :: MonadThrow m => Path b File -> m (Path b File)+withWikiExtension = replaceExtension wikiExtension