Permalink
Browse files

add </>| and |</> helpers

  • Loading branch information...
1 parent cf341f4 commit 00d043a2dfc22bd7d283840bd9425bfefc9d9450 @gregwebs gregwebs committed Mar 22, 2012
Showing with 13 additions and 2 deletions.
  1. +13 −2 Shelly.hs
View
15 Shelly.hs
@@ -38,8 +38,8 @@ module Shelly
, catchany, catch_sh, catchany_sh
, MemTime(..), time
, RunFailed(..)
- -- * mappend (<>) Text with a FilePath
- , (|<>), (<>|)
+ -- * mappend (<>) and (</>) Text with a FilePath
+ , (|<>), (<>|), (|</>), (</>|)
-- * convert between Text and FilePath
, toTextUnsafe, toTextWarn, fromText
-- * Re-export for your con
@@ -79,6 +79,9 @@ import System.Directory ( setPermissions, getPermissions, Permissions(..), getTe
infixr 5 <>|
infixr 5 |<>
+infixr 5 </>|
+infixr 5 |</>
+
-- | mappend a Text & FilePath. Warning: uses toTextUnsafe
(<>|) :: Text -> FilePath -> Text
(<>|) t fp = t `mappend` toTextUnsafe fp
@@ -87,6 +90,14 @@ infixr 5 |<>
(|<>) :: FilePath -> Text -> Text
(|<>) fp t = toTextUnsafe fp `mappend` t
+-- | </> a Text & FilePath. Warning: uses toTextUnsafe
+(</>|) :: Text -> FilePath -> Text
+(</>|) t fp = t `mappend` toTextUnsafe fp
+
+-- | </> a FilePath & Text. Warning: uses toTextUnsafe
+(|</>) :: FilePath -> Text -> Text
+(|</>) fp t = toTextUnsafe fp `mappend` t
+
-- | silently uses the Right or Left value of "Filesystem.Path.CurrentOS.toText"
toTextUnsafe :: FilePath -> Text
toTextUnsafe fp = LT.fromStrict $ case toText fp of

0 comments on commit 00d043a

Please sign in to comment.