@@ -441,15 +441,21 @@ relativeTo p1 p2 = relativeTo' (canonicalize p1) (canonicalize p2)
441441 relativeTo' cp1 cp2
442442 | identicalPath cp1 cp2 = pure Current
443443 | otherwise = do
444- mapInsidePath cp1
445- (\dirP -> do
446- Tuple cp1Path dirN <- peel dirP
444+ Tuple cp1Path name <- peel cp1
447445 rel <- relativeTo' cp1Path cp2
448- pure $ rel </> In Current dirN)
449- (\fileP -> do
450- Tuple cp1Path fileN <- peel fileP
451- rel <- relativeTo' cp1Path cp2
452- pure $ rel </> In Current fileN)
446+ pure $ overName name
447+ (\dirN -> rel </> In Current dirN)
448+ (\fileN -> rel </> In Current fileN)
449+ overName
450+ :: forall n a' s''
451+ . SplitDirOrFile n
452+ => Name n
453+ -> (Name Dir -> Path a' Dir s'' )
454+ -> (Name File -> Path a' File s'' )
455+ -> Path a' n s''
456+ overName p onDir onFile = case dirOrFileName p of
457+ Left p' -> unsafeCoerce $ onDir p'
458+ Right p' -> unsafeCoerce $ onFile p'
453459
454460-- | Attempts to sandbox a path relative to some directory. If successful, the sandboxed
455461-- | directory will be returned relative to the sandbox directory (although this can easily
@@ -460,16 +466,6 @@ relativeTo p1 p2 = relativeTo' (canonicalize p1) (canonicalize p2)
460466sandbox :: forall a b s . SplitDirOrFile b => Path a Dir Sandboxed -> Path a b s -> Maybe (Path Rel b Sandboxed )
461467sandbox p1 p2 = p2 `relativeTo` p1
462468
463- mapInsidePath :: forall a a' b s s' f . SplitDirOrFile b => Functor f => Path a b s -> (Path a Dir s -> f (Path a' Dir s' )) -> (Path a File s -> f (Path a' File s' )) -> f (Path a' b s' )
464- mapInsidePath p onDir onFile = case dirOrFile p of
465- Left p' -> unsafeCoerce $ onDir p'
466- Right p' -> unsafeCoerce $ onFile p'
467-
468- mapInsideName :: forall b . SplitDirOrFile b => Name b -> (Name Dir -> Name Dir ) -> (Name File -> Name File ) -> Name b
469- mapInsideName p onDir onFile = case dirOrFileName p of
470- Left p' -> unsafeCoerce $ onDir p'
471- Right p' -> unsafeCoerce $ onFile p'
472-
473469-- | Refines path segments but does not change anything else.
474470refine :: forall a b s . SplitDirOrFile b => (Name File -> Name File ) -> (Name Dir -> Name Dir ) -> Path a b s -> Path a b s
475471refine f d = go
0 commit comments