diff --git a/path.cabal b/path.cabal index c723327..8624b5b 100644 --- a/path.cabal +++ b/path.cabal @@ -1,5 +1,5 @@ name: path -version: 0.1.0 +version: 0.2.0 synopsis: Path description: Path license: BSD3 diff --git a/src/Path.hs b/src/Path.hs index c1e014a..18d18c7 100644 --- a/src/Path.hs +++ b/src/Path.hs @@ -27,7 +27,7 @@ module Path ,() ,stripDir ,isParentOf - ,parentAbs + ,parent ,filename -- * Conversion ,toFilePath @@ -234,17 +234,17 @@ isParentOf p l = -- -- The following properties hold: -- --- @parentAbs (parent \<\/> child) == parent@ +-- @parent (parent \<\/> child) == parent@ -- -- On the root, getting the parent is idempotent: -- --- @parentAbs (parentAbs \"\/\") = \"\/\"@ +-- @parent (parent \"\/\") = \"\/\"@ -- -parentAbs :: Path Abs t -> Path Abs Dir -parentAbs (Path fp) = +parent :: Path Abs t -> Path Abs Dir +parent (Path fp) = Path (normalizeDir (FilePath.takeDirectory (FilePath.dropTrailingPathSeparator fp))) --- | Extract the relative filename from a given location. +-- | Extract the file part of a path. -- -- The following properties hold: -- diff --git a/test/Main.hs b/test/Main.hs index d0c7002..1c58d18 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -42,14 +42,14 @@ operationFilename = operationParentAbs :: Spec operationParentAbs = do it "parentAbs (parent child) == parent" - (parentAbs ($(mkAbsDir "/foo") + (parent ($(mkAbsDir "/foo") $(mkRelDir "bar")) == $(mkAbsDir "/foo")) - it "parentAbs \"\" == \"\"" - (parentAbs $(mkAbsDir "/") == + it "parent \"\" == \"\"" + (parent $(mkAbsDir "/") == $(mkAbsDir "/")) - it "parentAbs (parentAbs \"\") == \"\"" - (parentAbs (parentAbs $(mkAbsDir "/")) == + it "parent (parent \"\") == \"\"" + (parent (parent $(mkAbsDir "/")) == $(mkAbsDir "/")) -- | The 'isParentOf' operation.