packages feed

validity-path (empty) → 0.1.0.0

raw patch · 4 files changed

+120/−0 lines, 4 filesdep +basedep +filepathdep +pathsetup-changed

Dependencies added: base, filepath, path, validity

Files

+ LICENSE view
@@ -0,0 +1,21 @@+The MIT License (MIT)++Copyright (c) 2016 Tom Sydney Kerckhove++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.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Data/Validity/Path.hs view
@@ -0,0 +1,71 @@+{-# LANGUAGE FlexibleInstances #-}++module Data.Validity.Path where++import Data.Validity++import Path+import Path.Internal++import Data.List (isInfixOf)++import qualified System.FilePath as FilePath++-- | An absolute path to a file is valid if:+--+-- * Its path is an absolute path+-- * Its path does not have a trailing path separator+-- * Its path is valid according to 'System.FilePath's definition.+-- * Its path does not contain '..'.+-- * Parsing the path and rendering it again results in the same path.+instance Validity (Path Abs File) where+    isValid p@(Path fp) =+        FilePath.isAbsolute fp &&+        not (FilePath.hasTrailingPathSeparator fp) &&+        FilePath.isValid fp &&+        not (".." `isInfixOf` fp) && (parseAbsFile fp == Just p)++-- | A relative path to a file is valid if:+--+-- * Its path is a relative path+-- * Its path does not have a trailing path separator+-- * Its path is valid according to 'System.FilePath's definition.+-- * Its path is not '.'+-- * Its path does not contain '..'.+-- * Parsing the path and rendering it again results in the same path.+instance Validity (Path Rel File) where+    isValid p@(Path fp) =+        FilePath.isRelative fp &&+        not (FilePath.hasTrailingPathSeparator fp) &&+        FilePath.isValid fp &&+        fp /= "." && not (".." `isInfixOf` fp) && (parseRelFile fp == Just p)++-- | An absolute path to a directory is valid if:+--+-- * Its path is an absolute path+-- * Its path has a trailing path separator+-- * Its path is valid according to 'System.FilePath's definition.+-- * Its path does not contain '..'.+-- * Parsing the path and rendering it again results in the same path.+instance Validity (Path Abs Dir) where+    isValid p@(Path fp) =+        FilePath.isAbsolute fp &&+        FilePath.hasTrailingPathSeparator fp &&+        FilePath.isValid fp &&+        not (".." `isInfixOf` fp) && (parseAbsDir fp == Just p)++-- | A relative path to a directory is valid if:+--+-- * Its path is a relative path+-- * Its path has a trailing path separator+-- * Its path is valid according to 'System.FilePath's definition.+-- * Its path is not '.'+-- * Its path does not contain '..'.+-- * Parsing the path and rendering it again results in the same path.+instance Validity (Path Rel Dir) where+    isValid p@(Path fp) =+        FilePath.isRelative fp &&+        FilePath.hasTrailingPathSeparator fp &&+        FilePath.isValid fp &&+        not (null fp) &&+        fp /= "." && not (".." `isInfixOf` fp) && (parseRelDir fp == Just p)
+ validity-path.cabal view
@@ -0,0 +1,26 @@+name:                validity-path+version:             0.1.0.0+synopsis:            Validity instances for Path+description:         Please see README.md+homepage:            https://github.com/NorfairKing/validity#readme+license:             MIT+license-file:        LICENSE+author:              Tom Sydney Kerckhove+maintainer:          syd.kerckhove@gmail.com+copyright:           Copyright: (c) 2016 Tom Sydney Kerckhove+category:            Validity+build-type:          Simple+cabal-version:       >=1.10++library+  hs-source-dirs:      src+  exposed-modules:     Data.Validity.Path+  build-depends:       base < 5+                     , validity+                     , path >= 0.5 && < 0.6+                     , filepath >= 1.4 && < 1.5+  default-language:    Haskell2010++source-repository head+  type:     git+  location: https://github.com/NorfairKing/validity