path-utils (empty) → 0.1.0.0
raw patch · 5 files changed
+101/−0 lines, 5 filesdep +basedep +exceptionsdep +path
Dependencies added: base, exceptions, path, split, text
Files
- ChangeLog.md +5/−0
- LICENSE +19/−0
- README.md +6/−0
- path-utils.cabal +40/−0
- src/Path/Utils.hs +31/−0
+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Changelog for path-utils++## (v0.1.0.0)++* Add handful of path utility functions.
+ LICENSE view
@@ -0,0 +1,19 @@+Copyright (c) 2020 Daniel Firth++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:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++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.
+ README.md view
@@ -0,0 +1,6 @@+# path-utils++Handful of simple utility functions for the+[path](https://hackage.haskell.org/package/path) library.++Most miscellany will be welcome here via pull request.
+ path-utils.cabal view
@@ -0,0 +1,40 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.34.2.+--+-- see: https://github.com/sol/hpack++name: path-utils+version: 0.1.0.0+synopsis: Handful of simple utility functions for the path library.+description: Handful of simple utility functiosn for the path library.+category: Filesystem+author: Daniel Firth+maintainer: dan.firth@homotopic.tech+copyright: 2020 Daniel Firth+license: MIT+license-file: LICENSE+build-type: Simple+extra-source-files:+ README.md+ ChangeLog.md++source-repository head+ type: git+ location: https://gitlab.com/homotopic-tech/path-utils++library+ exposed-modules:+ Path.Utils+ other-modules:+ Paths_path_utils+ hs-source-dirs:+ src+ ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints+ build-depends:+ base >=4.7 && <5+ , exceptions+ , path+ , split+ , text+ default-language: Haskell2010
+ src/Path/Utils.hs view
@@ -0,0 +1,31 @@+{- |+ Module : Path.Utils+ License : MIT+ Stability : experimental++Miscellaneous utility functions for the path library.+-}++module Path.Utils (+ (</$>)+, changeDir+, splitPath+) where++import Control.Monad.Catch+import qualified Data.Text as T+import Data.Text (Text)+import Data.List.Split+import Path++-- | Apply `(</>)` to every relative path inside a functor.+(</$>) :: Functor f => Path b Dir -> f (Path Rel t) -> f (Path b t)+(</$>) d = fmap (d </>)++-- | Change directory from src to dst.+changeDir :: MonadThrow m => Path b Dir -> Path b' Dir -> Path b t -> m (Path b' t)+changeDir src dst fp = (dst </>) <$> stripProperPrefix src fp++-- | Split a relative path into text sections.+splitPath :: Path Rel t -> [Text]+splitPath = fmap T.pack . splitOn "/" . toFilePath