@@ -44,6 +44,7 @@ module Streamly.Internal.FileSystem.OS_PATH.SegNode
4444 )
4545where
4646
47+ import Control.Monad ((>=>) )
4748import Language.Haskell.TH.Syntax (lift )
4849import Streamly.Internal.FileSystem.Path.Common (mkQ )
4950import Streamly.Internal.FileSystem.OS_PATH (OS_PATH (.. ))
@@ -161,39 +162,39 @@ instance IsPath OS_PATH (Unrooted (Dir OS_PATH)) where
161162
162163liftRootedDir :: Rooted (Dir OS_PATH ) -> Q Exp
163164liftRootedDir (Rooted (Dir p)) =
164- [| OsPath. unsafeFromString $ (lift $ OsPath. toString p ) :: Rooted (Dir OS_PATH )| ]
165+ [| unsafeFromPath ( OsPath. unsafeFromString $ (lift $ OsPath. toString $ toPath p) ) :: Rooted (Dir OS_PATH )| ]
165166
166167liftUnrootedDir :: Unrooted (Dir OS_PATH ) -> Q Exp
167168liftUnrootedDir (Unrooted (Dir p)) =
168- [| OsPath. unsafeFromString $ (lift $ OsPath. toString p ) :: Unrooted (Dir OS_PATH ) | ]
169+ [| unsafeFromPath ( OsPath. unsafeFromString $ (lift $ OsPath. toString $ toPath p) ) :: Unrooted (Dir OS_PATH ) | ]
169170
170171liftRootedFile :: Rooted (File OS_PATH ) -> Q Exp
171172liftRootedFile (Rooted (File p)) =
172- [| OsPath. unsafeFromString $ (lift $ OsPath. toString p ) :: Rooted (File OS_PATH )| ]
173+ [| unsafeFromPath ( OsPath. unsafeFromString $ (lift $ OsPath. toString $ toPath p) ) :: Rooted (File OS_PATH )| ]
173174
174175liftUnrootedFile :: Unrooted (File OS_PATH ) -> Q Exp
175176liftUnrootedFile (Unrooted (File p)) =
176- [| OsPath. unsafeFromString $ (lift $ OsPath. toString p ) :: Unrooted (File OS_PATH )| ]
177+ [| unsafeFromPath ( OsPath. unsafeFromString $ (lift $ OsPath. toString $ toPath p) ) :: Unrooted (File OS_PATH )| ]
177178
178179-- | Generates a Haskell expression of type @Rooted (Dir OS_PATH)@.
179180--
180181rtdirE :: String -> Q Exp
181- rtdirE = either (error . show ) liftRootedDir . OsPath. fromString
182+ rtdirE = either (error . show ) liftRootedDir . ( OsPath. fromString >=> fromPath)
182183
183184-- | Generates a Haskell expression of type @Unrooted (Dir OS_PATH)@.
184185--
185186urdirE :: String -> Q Exp
186- urdirE = either (error . show ) liftUnrootedDir . OsPath. fromString
187+ urdirE = either (error . show ) liftUnrootedDir . ( OsPath. fromString >=> fromPath)
187188
188189-- | Generates a Haskell expression of type @Rooted (File OS_PATH)@.
189190--
190191rtfileE :: String -> Q Exp
191- rtfileE = either (error . show ) liftRootedFile . OsPath. fromString
192+ rtfileE = either (error . show ) liftRootedFile . ( OsPath. fromString >=> fromPath)
192193
193194-- | Generates a Haskell expression of type @Unrooted (File OS_PATH)@.
194195--
195196urfileE :: String -> Q Exp
196- urfileE = either (error . show ) liftUnrootedFile . OsPath. fromString
197+ urfileE = either (error . show ) liftUnrootedFile . ( OsPath. fromString >=> fromPath)
197198
198199------------------------------------------------------------------------------
199200-- Statically Verified Literals
@@ -206,31 +207,31 @@ urfileE = either (error . show) liftUnrootedFile . OsPath.fromString
206207
207208-- | Generates a @Rooted (Dir OS_PATH)@ type from a quoted literal.
208209--
209- -- >>> Path.toString ([rtdir|/usr|] :: Rooted (Dir PosixPath))
210+ -- >>> Path.toString (Path.toPath ( [rtdir|/usr|] :: Rooted (Dir PosixPath) ))
210211-- "/usr"
211212--
212213rtdir :: QuasiQuoter
213214rtdir = mkQ rtdirE
214215
215216-- | Generates a @Unrooted (Dir OS_PATH)@ type from a quoted literal.
216217--
217- -- >>> Path.toString ([urdir|usr|] :: Unrooted (Dir PosixPath))
218+ -- >>> Path.toString (Path.toPath ( [urdir|usr|] :: Unrooted (Dir PosixPath) ))
218219-- "usr"
219220--
220221urdir :: QuasiQuoter
221222urdir = mkQ urdirE
222223
223224-- | Generates a @Rooted (File OS_PATH)@ type from a quoted literal.
224225--
225- -- >>> Path.toString ([rtfile|/x.txt|] :: Rooted (File PosixPath))
226+ -- >>> Path.toString (Path.toPath ( [rtfile|/x.txt|] :: Rooted (File PosixPath) ))
226227-- "/x.txt"
227228--
228229rtfile :: QuasiQuoter
229230rtfile = mkQ rtfileE
230231
231232-- | Generates a @Unrooted (File OS_PATH)@ type from a quoted literal.
232233--
233- -- >>> Path.toString ([urfile|x.txt|] :: Unrooted (File PosixPath))
234+ -- >>> Path.toString (Path.toPath ( [urfile|x.txt|] :: Unrooted (File PosixPath) ))
234235-- "x.txt"
235236--
236237urfile :: QuasiQuoter
@@ -245,26 +246,26 @@ urfile = mkQ urfileE
245246-- If the second path does not have 'File' or 'Dir' information then the return
246247-- type too cannot have it.
247248--
248- -- >> Path.toString (SegNode.join [rtdir|/usr|] [br|bin|] :: Rooted PosixPath)
249+ -- >> Path.toString (Path.toPath ( SegNode.join [rtdir|/usr|] [br|bin|] :: Rooted PosixPath) )
249250-- "/usr/bin"
250- -- >> Path.toString (SegNode.join [urdir|usr|] [br|bin|] :: Unrooted PosixPath)
251+ -- >> Path.toString (Path.toPath ( SegNode.join [urdir|usr|] [br|bin|] :: Unrooted PosixPath) )
251252-- "usr/bin"
252253--
253- -- >> Path.toString (SegNode.join [rt|/usr|] [br|bin|] :: Rooted PosixPath)
254+ -- >> Path.toString (Path.toPath ( SegNode.join [rt|/usr|] [br|bin|] :: Rooted PosixPath) )
254255-- "/usr/bin"
255- -- >> Path.toString (SegNode.join [br|usr|] [br|bin|] :: Unrooted PosixPath)
256+ -- >> Path.toString (Path.toPath ( SegNode.join [br|usr|] [br|bin|] :: Unrooted PosixPath) )
256257-- "usr/bin"
257258--
258259-- If the second path has 'File' or 'Dir' information then the return type
259260-- also has it.
260261--
261- -- >> Path.toString (SegNode.join [rt|/usr|] [urdir|bin|] :: Rooted (Dir PosixPath))
262+ -- >> Path.toString (Path.toPath ( SegNode.join [rt|/usr|] [urdir|bin|] :: Rooted (Dir PosixPath) ))
262263-- "/usr/bin"
263- -- >> Path.toString (SegNode.join [rt|/usr|] [urfile|bin|] :: Rooted (File PosixPath))
264+ -- >> Path.toString (Path.toPath ( SegNode.join [rt|/usr|] [urfile|bin|] :: Rooted (File PosixPath) ))
264265-- "/usr/bin"
265- -- >> Path.toString (SegNode.join [br|usr|] [urdir|bin|] :: Unrooted (Dir PosixPath))
266+ -- >> Path.toString (Path.toPath ( SegNode.join [br|usr|] [urdir|bin|] :: Unrooted (Dir PosixPath) ))
266267-- "usr/bin"
267- -- >> Path.toString (SegNode.join [br|usr|] [urfile|bin|] :: Unrooted (File PosixPath))
268+ -- >> Path.toString (Path.toPath ( SegNode.join [br|usr|] [urfile|bin|] :: Unrooted (File PosixPath) ))
268269-- "usr/bin"
269270--
270271-- Type error cases:
@@ -290,13 +291,13 @@ join a (Unrooted c) = unsafeFromPath $ OS_NAME.unsafeJoin (toPath a) (toPath c)
290291
291292-- | Append a branch type path to a directory.
292293--
293- -- >>> Path.toString (SegNode.join [rtdir|/usr|] [urdir|bin|] :: Rooted (Dir PosixPath))
294+ -- >>> Path.toString (Path.toPath ( SegNode.join [rtdir|/usr|] [urdir|bin|] :: Rooted (Dir PosixPath) ))
294295-- "/usr/bin"
295- -- >>> Path.toString (SegNode.join [rtdir|/usr|] [urfile|bin|] :: Rooted (File PosixPath))
296+ -- >>> Path.toString (Path.toPath ( SegNode.join [rtdir|/usr|] [urfile|bin|] :: Rooted (File PosixPath) ))
296297-- "/usr/bin"
297- -- >>> Path.toString (SegNode.join [urdir|usr|] [urdir|bin|] :: Unrooted (Dir PosixPath))
298+ -- >>> Path.toString (Path.toPath ( SegNode.join [urdir|usr|] [urdir|bin|] :: Unrooted (Dir PosixPath) ))
298299-- "usr/bin"
299- -- >>> Path.toString (SegNode.join [urdir|usr|] [urfile|bin|] :: Unrooted (File PosixPath))
300+ -- >>> Path.toString (Path.toPath ( SegNode.join [urdir|usr|] [urfile|bin|] :: Unrooted (File PosixPath) ))
300301-- "usr/bin"
301302--
302303{-# INLINE join #-}
0 commit comments