Skip to content

Commit 5a02f8f

Browse files
Rename "extend" to "join" in Path module
1 parent 1333b00 commit 5a02f8f

File tree

11 files changed

+104
-104
lines changed

11 files changed

+104
-104
lines changed

core/src/Streamly/FileSystem/Path.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ module Streamly.FileSystem.Path
103103
, isUnrooted
104104

105105
-- * Joining
106-
, unsafeExtend
107-
, extend
108-
, extendByString
106+
, unsafeJoin
107+
, join
108+
, joinStr
109109

110110
-- * Splitting root
111111
, splitRoot

core/src/Streamly/FileSystem/Path/Node.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module Streamly.FileSystem.Path.Node
3030
, fileE
3131

3232
-- * Operations
33-
, extend
33+
, join
3434
)
3535
where
3636

core/src/Streamly/FileSystem/Path/Seg.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module Streamly.FileSystem.Path.Seg
3030
, urE
3131

3232
-- * Operations
33-
, extend
33+
, join
3434
)
3535
where
3636

core/src/Streamly/FileSystem/Path/SegNode.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module Streamly.FileSystem.Path.SegNode
3030
, urfileE
3131

3232
-- * Operations
33-
, extend
33+
, join
3434
)
3535
where
3636

core/src/Streamly/Internal/FileSystem/DirIO.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ toStreamWithBufferOf chunkSize h = AS.concat $ toChunksWithBufferOf chunkSize h
314314
eitherReaderPaths ::(MonadIO m, MonadCatch m) => (ReadOptions -> ReadOptions) ->
315315
Unfold m Path (Either Path Path)
316316
eitherReaderPaths f =
317-
let (</>) = Path.extend
317+
let (</>) = Path.join
318318
in UF.mapM2 (\dir -> return . bimap (dir </>) (dir </>)) (eitherReader f)
319319

320320
--
@@ -359,7 +359,7 @@ readEither f = S.unfold (eitherReader f)
359359
readEitherPaths :: (MonadIO m, MonadCatch m) => (ReadOptions -> ReadOptions) ->
360360
Path -> Stream m (Either Path Path)
361361
readEitherPaths f dir =
362-
let (</>) = Path.extend
362+
let (</>) = Path.join
363363
in fmap (bimap (dir </>) (dir </>)) $ readEither f dir
364364

365365
#if defined(mingw32_HOST_OS) || defined(__MINGW32__)

core/src/Streamly/Internal/FileSystem/Posix/ReadDir.hsc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ readEitherByteChunksAt confMod (ppath, alldirs) =
931931
{-
932932
if ndirs > 64
933933
then do
934-
let fpath = Path.unsafeExtend ppath curdir
934+
let fpath = Path.unsafeJoin ppath curdir
935935
return $ Yield
936936
(Left (fpath, dirs1))
937937
(ByteChunksAtLoop pfd dirp curdir xs [] 0 mbarr pos1)
@@ -961,7 +961,7 @@ readEitherByteChunksAt confMod (ppath, alldirs) =
961961
-- help parallelize more in IO bound case.
962962
if ndirs > 0
963963
then do
964-
let fpath = Path.unsafeExtend ppath curdir
964+
let fpath = Path.unsafeJoin ppath curdir
965965
return $ Yield
966966
(Left (fpath, dirs))
967967
(ByteChunksAtInit pfd xs mbarr pos)

core/src/Streamly/Internal/FileSystem/PosixPath.hs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,19 @@ module Streamly.Internal.FileSystem.OS_PATH_TYPE
159159
, isUnrooted
160160

161161
-- * Joining
162-
, extendByString
162+
, joinStr
163163
-- , concat
164-
, unsafeExtend
164+
, unsafeJoin
165165
#ifndef IS_WINDOWS
166-
, extendByCString
167-
, extendByCString'
166+
, joinCStr
167+
, joinCStr'
168168
#endif
169-
, extend
170-
, extendDir
169+
, join
170+
, joinDir
171171
, unsafeJoinPaths
172172

173173
-- * Splitting
174-
-- | Note: you can use 'unsafeExtend' as a replacement for the joinDrive
174+
-- | Note: you can use 'unsafeJoin' as a replacement for the joinDrive
175175
-- function in the filepath package.
176176
, splitRoot
177177
, splitPath
@@ -417,9 +417,9 @@ addTrailingSeparator p@(OS_PATH _arr) =
417417
#ifdef IS_WINDOWS
418418
if Array.unsafeGetIndexRev 0 _arr == Common.charToWord ':'
419419
then p
420-
else unsafeExtend p sep
420+
else unsafeJoin p sep
421421
#else
422-
unsafeExtend p sep
422+
unsafeJoin p sep
423423
#endif
424424

425425
where
@@ -717,13 +717,13 @@ fromString_ x =
717717
Left e -> throw e
718718
Right v -> v
719719

720-
-- | Extend a path by adding a separator followed by the supplied string to it.
720+
-- | Append a separator followed by the supplied string to a path.
721721
--
722722
-- Throws 'InvalidPath' if the resulting path is not a valid path as per
723723
-- 'validatePath'.
724724
--
725-
extendByString :: OS_PATH_TYPE -> [Char] -> OS_PATH_TYPE
726-
extendByString (OS_PATH a) b =
725+
joinStr :: OS_PATH_TYPE -> [Char] -> OS_PATH_TYPE
726+
joinStr (OS_PATH a) b =
727727
OS_PATH $
728728
Common.append Common.OS_NAME
729729
(Common.toString Unicode.UNICODE_DECODER) a (encodeString b)
@@ -891,9 +891,9 @@ isUnrooted :: OS_PATH_TYPE -> Bool
891891
isUnrooted = not . isRooted
892892

893893
#ifndef IS_WINDOWS
894-
-- | Like 'extend' but does not check if the second path is rooted.
894+
-- | Like 'join' but does not check if the second path is rooted.
895895
--
896-
-- >>> f a b = Path.toString $ Path.unsafeExtend (Path.fromString_ a) (Path.fromString_ b)
896+
-- >>> f a b = Path.toString $ Path.unsafeJoin (Path.fromString_ a) (Path.fromString_ b)
897897
--
898898
-- >>> f "x" "y"
899899
-- "x/y"
@@ -904,21 +904,21 @@ isUnrooted = not . isRooted
904904
-- >>> f "x/" "/y"
905905
-- "x/y"
906906
--
907-
{-# INLINE unsafeExtend #-}
908-
unsafeExtend :: OS_PATH_TYPE -> OS_PATH_TYPE -> OS_PATH_TYPE
909-
unsafeExtend (OS_PATH a) (OS_PATH b) =
907+
{-# INLINE unsafeJoin #-}
908+
unsafeJoin :: OS_PATH_TYPE -> OS_PATH_TYPE -> OS_PATH_TYPE
909+
unsafeJoin (OS_PATH a) (OS_PATH b) =
910910
OS_PATH
911911
$ Common.unsafeAppend
912912
Common.OS_NAME (Common.toString Unicode.UNICODE_DECODER) a b
913913

914914
-- If you want to avoid runtime failure use the typesafe
915915
-- Streamly.FileSystem.OS_PATH_TYPE.Seg module.
916916

917-
-- | Extend a OS_PATH_TYPE by adding a separator followed by another path to
918-
-- it. Fails if the second path is a rooted path. Use 'unsafeExtend' to avoid
919-
-- failure if you know it is ok to append the rooted path.
917+
-- | Append a separator followed by another path to a OS_PATH_TYPE. Fails if
918+
-- the second path is a rooted path. Use 'unsafeJoin' to avoid failure if you
919+
-- know it is ok to append the rooted path.
920920
--
921-
-- >>> f a b = Path.toString $ Path.extend a b
921+
-- >>> f a b = Path.toString $ Path.join a b
922922
--
923923
-- >>> f [path|/usr|] [path|bin|]
924924
-- "/usr/bin"
@@ -927,23 +927,23 @@ unsafeExtend (OS_PATH a) (OS_PATH b) =
927927
-- >>> fails (f [path|/usr|] [path|/bin|])
928928
-- True
929929
--
930-
extend :: OS_PATH_TYPE -> OS_PATH_TYPE -> OS_PATH_TYPE
931-
extend (OS_PATH a) (OS_PATH b) =
930+
join :: OS_PATH_TYPE -> OS_PATH_TYPE -> OS_PATH_TYPE
931+
join (OS_PATH a) (OS_PATH b) =
932932
OS_PATH
933933
$ Common.append
934934
Common.OS_NAME (Common.toString Unicode.UNICODE_DECODER) a b
935935

936-
-- | A stricter version of 'extend' which requires the first path to be a
936+
-- | A stricter version of 'join' which requires the first path to be a
937937
-- directory like path i.e. having a trailing separator.
938938
--
939-
-- >>> f a b = Path.toString $ Path.extendDir a b
939+
-- >>> f a b = Path.toString $ Path.joinDir a b
940940
--
941941
-- >>> fails $ f [path|/usr|] [path|bin|]
942942
-- True
943943
--
944-
extendDir ::
944+
joinDir ::
945945
OS_PATH_TYPE -> OS_PATH_TYPE -> OS_PATH_TYPE
946-
extendDir
946+
joinDir
947947
(OS_PATH a) (OS_PATH b) =
948948
OS_PATH
949949
$ Common.append'
@@ -954,21 +954,21 @@ extendDir
954954
-- XXX add appendCWString for Windows?
955955

956956
#ifndef IS_WINDOWS
957-
-- | Append a separator and a CString to the Array. This is like 'unsafeExtend'
957+
-- | Append a separator and a CString to the Array. This is like 'unsafeJoin'
958958
-- but always inserts a separator between the two paths even if the first path
959959
-- has a trailing separator or second path has a leading separator.
960960
--
961-
extendByCString :: OS_PATH_TYPE -> CString -> IO OS_PATH_TYPE
962-
extendByCString (OS_PATH a) str =
961+
joinCStr :: OS_PATH_TYPE -> CString -> IO OS_PATH_TYPE
962+
joinCStr (OS_PATH a) str =
963963
fmap OS_PATH
964964
$ Common.appendCString
965965
Common.OS_NAME a str
966966

967-
-- | Like 'appendCString' but creates a pinned path.
967+
-- | Like 'joinCStr' but creates a pinned path.
968968
--
969-
extendByCString' ::
969+
joinCStr' ::
970970
OS_PATH_TYPE -> CString -> IO OS_PATH_TYPE
971-
extendByCString'
971+
joinCStr'
972972
(OS_PATH a) str =
973973
fmap OS_PATH
974974
$ Common.appendCString'
@@ -998,7 +998,7 @@ unsafeJoinPaths = undefined
998998
-- Some filepath package equivalent idioms:
999999
--
10001000
-- >>> splitDrive = Path.splitRoot
1001-
-- >>> joinDrive = Path.unsafeExtend
1001+
-- >>> joinDrive = Path.unsafeJoin
10021002
-- >>> takeDrive = fmap fst . Path.splitRoot
10031003
-- >>> dropDrive x = Path.splitRoot x >>= snd
10041004
-- >>> hasDrive = isJust . Path.splitRoot
@@ -1360,7 +1360,7 @@ replaceExtension (OS_PATH _a) = undefined
13601360
-- present.
13611361
--
13621362
-- >>> takeFileName = fmap snd . Path.splitFile
1363-
-- >>> replaceDirectory p x = fmap (flip Path.extend x) (takeFileName p)
1363+
-- >>> replaceDirectory p x = fmap (flip Path.join x) (takeFileName p)
13641364
--
13651365
-- >>> fmap Path.toString $ Path.takeFileName [path|/home/user/file.txt|]
13661366
-- Just "file.txt"
@@ -1394,7 +1394,7 @@ takeFileBase = fmap dropExtension . takeFileName
13941394
-- | Returns the parent directory of the given OS_PATH_TYPE, if any.
13951395
--
13961396
-- >>> takeDirectory x = Path.splitFile x >>= fst
1397-
-- >>> replaceFileName p x = fmap (flip Path.extend x) (takeDirectory p)
1397+
-- >>> replaceFileName p x = fmap (flip Path.join x) (takeDirectory p)
13981398
--
13991399
-- To get an equivalent to takeDirectory from filepath use
14001400
-- 'dropTrailingSeparators' on the result.

core/src/Streamly/Internal/FileSystem/PosixPath/Node.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module Streamly.Internal.FileSystem.OS_PATH.Node
4242
, fileE
4343

4444
-- * Operations
45-
, extend
45+
, join
4646
)
4747
where
4848

@@ -147,15 +147,15 @@ file = mkQ fileE
147147

148148
-- | Append a 'Dir' or 'File' path to a 'Dir' path.
149149
--
150-
-- >>> Path.toString (Node.extend [dir|/usr|] [dir|bin|] :: Dir PosixPath)
150+
-- >>> Path.toString (Node.join [dir|/usr|] [dir|bin|] :: Dir PosixPath)
151151
-- "/usr/bin"
152-
-- >>> Path.toString (Node.extend [dir|/usr|] [file|bin|] :: File PosixPath)
152+
-- >>> Path.toString (Node.join [dir|/usr|] [file|bin|] :: File PosixPath)
153153
-- "/usr/bin"
154154
--
155155
-- Fails if the second path is a specific location and not a path segment.
156156
--
157-
{-# INLINE extend #-}
158-
extend :: (IsPath OS_PATH (a OS_PATH), IsNode (a OS_PATH)) =>
157+
{-# INLINE join #-}
158+
join :: (IsPath OS_PATH (a OS_PATH), IsNode (a OS_PATH)) =>
159159
Dir OS_PATH -> a OS_PATH -> a OS_PATH
160-
extend (Dir a) b =
161-
unsafeFromPath $ OsPath.unsafeExtend (toPath a) (toPath b)
160+
join (Dir a) b =
161+
unsafeFromPath $ OsPath.unsafeJoin (toPath a) (toPath b)

core/src/Streamly/Internal/FileSystem/PosixPath/Seg.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module Streamly.Internal.FileSystem.OS_PATH.Seg
4747
, urE
4848

4949
-- * Operations
50-
, extend
50+
, join
5151
)
5252
where
5353

@@ -156,16 +156,16 @@ ur = mkQ urE
156156

157157
-- | Append a 'Unrooted' type path to a 'Rooted' path or 'Unrooted' path.
158158
--
159-
-- >>> Path.toString (Seg.extend [rt|/usr|] [ur|bin|] :: Rooted PosixPath)
159+
-- >>> Path.toString (Seg.join [rt|/usr|] [ur|bin|] :: Rooted PosixPath)
160160
-- "/usr/bin"
161-
-- >>> Path.toString (Seg.extend [ur|usr|] [ur|bin|] :: Unrooted PosixPath)
161+
-- >>> Path.toString (Seg.join [ur|usr|] [ur|bin|] :: Unrooted PosixPath)
162162
-- "usr/bin"
163163
--
164-
{-# INLINE extend #-}
165-
extend ::
164+
{-# INLINE join #-}
165+
join ::
166166
(
167167
IsSeg (a OS_PATH)
168168
, IsPath OS_PATH (a OS_PATH)
169169
) => a OS_PATH -> Unrooted OS_PATH -> a OS_PATH
170-
extend a (Unrooted c) =
171-
unsafeFromPath $ OsPath.unsafeExtend (toPath a) (toPath c)
170+
join a (Unrooted c) =
171+
unsafeFromPath $ OsPath.unsafeJoin (toPath a) (toPath c)

0 commit comments

Comments
 (0)