Skip to content

Commit 40a3cb4

Browse files
committed
simplify relativify and absolutify
1 parent 6e69d23 commit 40a3cb4

File tree

1 file changed

+5
-25
lines changed

1 file changed

+5
-25
lines changed

src/Data/Path/Pathy.purs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -453,31 +453,11 @@ identicalPath
453453
=> Path a b s -> Path a' b' s' -> Boolean
454454
identicalPath p1 p2 = show p1 == show p2
455455

456-
relativify :: forall a. SplitDirOrFile a => Path Abs a Sandboxed -> Path Rel a Sandboxed
457-
relativify p = case dirOrFile p of
458-
Left d ->
459-
joinSplit $ asRel $ viewAbsDir d
460-
Right f ->
461-
let (Tuple d name) = viewAbsFile f
462-
in joinSplit $ asRel d </> file' name
463-
where
464-
joinSplit :: forall x. Path Rel x Sandboxed -> Path Rel a Sandboxed
465-
joinSplit = unsafeCoerce
466-
asRel :: DirPathView -> Path Rel Dir Sandboxed
467-
asRel = foldl (\p n -> p </> dir' n) currentDir
468-
469-
absolutify :: forall a. SplitDirOrFile a => Path Rel a Sandboxed -> Path Abs a Sandboxed
470-
absolutify p = case dirOrFile p of
471-
Left d ->
472-
joinSplit $ asAbs $ viewRelDir d
473-
Right f ->
474-
let (Tuple d name) = viewRelFile f
475-
in joinSplit $ asAbs d </> file' name
476-
where
477-
joinSplit :: forall x. Path Abs x Sandboxed -> Path Abs a Sandboxed
478-
joinSplit = unsafeCoerce
479-
asAbs :: DirPathView -> Path Abs Dir Sandboxed
480-
asAbs = foldl (\p n -> p </> dir' n) rootDir
456+
relativify :: forall a b. Path Abs a b -> Path Rel a b
457+
relativify = unsafeCoerce
458+
459+
absolutify :: forall a b. Path Rel a b -> Path Abs a b
460+
absolutify = unsafeCoerce
481461

482462

483463
-- | Makes one path relative to another reference path, if possible, otherwise

0 commit comments

Comments
 (0)