{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE NoImplicitPrelude #-}

module System.FilePath.FilePather.Posix(
  splitExtension
, takeExtension
, replaceExtension
, dropExtension
, addExtension
, hasExtension
, splitExtensions
, dropExtensions
, takeExtensions
, replaceExtensions
, isExtensionOf
, stripExtension
, splitFileName
, takeFileName
, replaceFileName
, dropFileName
, takeBaseName
, replaceBaseName
, takeDirectory
, replaceDirectory
, combine
, splitPath
, joinPath
, splitDirectories
, splitDrive
, joinDrive
, takeDrive
, hasDrive
, dropDrive
, isDrive
, hasTrailingPathSeparator
, addTrailingPathSeparator
, dropTrailingPathSeparator
, normalise
, equalFilePath
, makeRelative
, isRelative
, isAbsolute
, isValid
, makeValid
, module SFP
) where

import Control.Applicative ( Applicative )
import Control.Category((.))
import Control.Lens ( (#) )
import Data.String( String )
import Data.Bool( Bool )
import Data.Maybe ( Maybe )
import qualified System.FilePath as FP
import System.FilePath as SFP(FilePath, pathSeparator, pathSeparators, isPathSeparator, extSeparator, isExtSeparator, splitSearchPath, (-<.>), (</>))
import System.FilePath.FilePather.ToFilePath
    ( ToFilePath, toFilePath )
import System.FilePath.FilePather.ReadFilePath
    ( ReadFilePathT, liftReadFilePath )

splitExtension ::
  Applicative f =>
  ReadFilePathT f (String, String)
splitExtension :: ReadFilePathT f (String, String)
splitExtension =
  (String -> (String, String)) -> ReadFilePathT f (String, String)
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> (String, String)
FP.splitExtension

takeExtension ::
  Applicative f =>
  ReadFilePathT f String
takeExtension :: ReadFilePathT f String
takeExtension =
  (String -> String) -> ReadFilePathT f String
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String
FP.takeExtension

replaceExtension ::
  Applicative f =>
  ReadFilePathT f (String -> FilePath)
replaceExtension :: ReadFilePathT f (String -> String)
replaceExtension =
  (String -> String -> String) -> ReadFilePathT f (String -> String)
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String -> String
FP.replaceExtension

dropExtension ::
  Applicative f =>
  ReadFilePathT f FilePath
dropExtension :: ReadFilePathT f String
dropExtension =
  (String -> String) -> ReadFilePathT f String
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String
FP.dropExtensions

addExtension ::
  Applicative f =>
  ReadFilePathT f (String -> FilePath)
addExtension :: ReadFilePathT f (String -> String)
addExtension =
  (String -> String -> String) -> ReadFilePathT f (String -> String)
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String -> String
FP.addExtension

hasExtension ::
  Applicative f =>
  ReadFilePathT f Bool
hasExtension :: ReadFilePathT f Bool
hasExtension =
  (String -> Bool) -> ReadFilePathT f Bool
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> Bool
FP.hasExtension

splitExtensions ::
  Applicative f =>
  ReadFilePathT f (FilePath, String)
splitExtensions :: ReadFilePathT f (String, String)
splitExtensions =
  (String -> (String, String)) -> ReadFilePathT f (String, String)
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> (String, String)
FP.splitExtensions

dropExtensions ::
  Applicative f =>
  ReadFilePathT f FilePath
dropExtensions :: ReadFilePathT f String
dropExtensions =
  (String -> String) -> ReadFilePathT f String
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String
FP.dropExtensions

takeExtensions ::
  Applicative f =>
  ReadFilePathT f String
takeExtensions :: ReadFilePathT f String
takeExtensions =
  (String -> String) -> ReadFilePathT f String
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String
FP.takeExtensions

replaceExtensions ::
  Applicative f =>
  ReadFilePathT f (String -> FilePath)
replaceExtensions :: ReadFilePathT f (String -> String)
replaceExtensions =
  (String -> String -> String) -> ReadFilePathT f (String -> String)
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String -> String
FP.replaceExtensions

isExtensionOf ::
  Applicative f =>
  String
  -> ReadFilePathT f Bool
isExtensionOf :: String -> ReadFilePathT f Bool
isExtensionOf =
  (String -> Bool) -> ReadFilePathT f Bool
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath ((String -> Bool) -> ReadFilePathT f Bool)
-> (String -> String -> Bool) -> String -> ReadFilePathT f Bool
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> String -> Bool
FP.isExtensionOf

stripExtension ::
  Applicative f =>
  String
  -> ReadFilePathT f (Maybe FilePath)
stripExtension :: String -> ReadFilePathT f (Maybe String)
stripExtension =
  (String -> Maybe String) -> ReadFilePathT f (Maybe String)
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath ((String -> Maybe String) -> ReadFilePathT f (Maybe String))
-> (String -> String -> Maybe String)
-> String
-> ReadFilePathT f (Maybe String)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> String -> Maybe String
FP.stripExtension

splitFileName ::
  Applicative f =>
  ReadFilePathT f (String, String)
splitFileName :: ReadFilePathT f (String, String)
splitFileName =
  (String -> (String, String)) -> ReadFilePathT f (String, String)
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> (String, String)
FP.splitFileName

takeFileName ::
  Applicative f =>
  ReadFilePathT f String
takeFileName :: ReadFilePathT f String
takeFileName =
  (String -> String) -> ReadFilePathT f String
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String
FP.takeFileName

replaceFileName ::
  Applicative f =>
  ReadFilePathT f (String -> FilePath)
replaceFileName :: ReadFilePathT f (String -> String)
replaceFileName =
  (String -> String -> String) -> ReadFilePathT f (String -> String)
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String -> String
FP.replaceFileName

dropFileName ::
  Applicative f =>
  ReadFilePathT f FilePath
dropFileName :: ReadFilePathT f String
dropFileName =
  (String -> String) -> ReadFilePathT f String
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String
FP.dropFileName

takeBaseName ::
  Applicative f =>
  ReadFilePathT f String
takeBaseName :: ReadFilePathT f String
takeBaseName =
  (String -> String) -> ReadFilePathT f String
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String
FP.takeBaseName

replaceBaseName ::
  Applicative f =>
  ReadFilePathT f (String -> FilePath)
replaceBaseName :: ReadFilePathT f (String -> String)
replaceBaseName =
  (String -> String -> String) -> ReadFilePathT f (String -> String)
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String -> String
FP.replaceBaseName

takeDirectory ::
  Applicative f =>
  ReadFilePathT f FilePath
takeDirectory :: ReadFilePathT f String
takeDirectory =
  (String -> String) -> ReadFilePathT f String
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String
FP.takeDirectory

replaceDirectory ::
  Applicative f =>
  ReadFilePathT f (String -> FilePath)
replaceDirectory :: ReadFilePathT f (String -> String)
replaceDirectory =
  (String -> String -> String) -> ReadFilePathT f (String -> String)
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String -> String
FP.replaceDirectory

combine ::
  Applicative f =>
  ReadFilePathT f (FilePath -> FilePath)
combine :: ReadFilePathT f (String -> String)
combine =
  (String -> String -> String) -> ReadFilePathT f (String -> String)
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String -> String
FP.combine

splitPath ::
  Applicative f =>
  ReadFilePathT f [FilePath]
splitPath :: ReadFilePathT f [String]
splitPath =
  (String -> [String]) -> ReadFilePathT f [String]
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> [String]
FP.splitPath

joinPath ::
  ToFilePath [FilePath]
joinPath :: ToFilePath [String]
joinPath =
  Tagged ([String] -> String) (Identity ([String] -> String))
-> Tagged (ToFilePath [String]) (Identity (ToFilePath [String]))
forall a a'.
Iso (ToFilePath a) (ToFilePath a') (a -> String) (a' -> String)
toFilePath (Tagged ([String] -> String) (Identity ([String] -> String))
 -> Tagged (ToFilePath [String]) (Identity (ToFilePath [String])))
-> ([String] -> String) -> ToFilePath [String]
forall t b. AReview t b -> b -> t
# [String] -> String
FP.joinPath

splitDirectories ::
  Applicative f =>
  ReadFilePathT f [FilePath]
splitDirectories :: ReadFilePathT f [String]
splitDirectories =
  (String -> [String]) -> ReadFilePathT f [String]
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> [String]
FP.splitDirectories

splitDrive ::
  Applicative f =>
  ReadFilePathT f (FilePath, FilePath)
splitDrive :: ReadFilePathT f (String, String)
splitDrive =
  (String -> (String, String)) -> ReadFilePathT f (String, String)
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> (String, String)
FP.splitDrive

joinDrive ::
  Applicative f =>
  ReadFilePathT f (FilePath -> FilePath)
joinDrive :: ReadFilePathT f (String -> String)
joinDrive =
  (String -> String -> String) -> ReadFilePathT f (String -> String)
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String -> String
FP.joinDrive

takeDrive ::
  Applicative f =>
  ReadFilePathT f FilePath
takeDrive :: ReadFilePathT f String
takeDrive =
  (String -> String) -> ReadFilePathT f String
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String
FP.takeDrive

hasDrive ::
  Applicative f =>
  ReadFilePathT f Bool
hasDrive :: ReadFilePathT f Bool
hasDrive =
  (String -> Bool) -> ReadFilePathT f Bool
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> Bool
FP.hasDrive

dropDrive ::
  Applicative f =>
  ReadFilePathT f FilePath
dropDrive :: ReadFilePathT f String
dropDrive =
  (String -> String) -> ReadFilePathT f String
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String
FP.dropDrive

isDrive ::
  Applicative f =>
  ReadFilePathT f Bool
isDrive :: ReadFilePathT f Bool
isDrive =
  (String -> Bool) -> ReadFilePathT f Bool
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> Bool
FP.isDrive

hasTrailingPathSeparator ::
  Applicative f =>
  ReadFilePathT f Bool
hasTrailingPathSeparator :: ReadFilePathT f Bool
hasTrailingPathSeparator =
  (String -> Bool) -> ReadFilePathT f Bool
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> Bool
FP.hasTrailingPathSeparator

addTrailingPathSeparator ::
  Applicative f =>
  ReadFilePathT f FilePath
addTrailingPathSeparator :: ReadFilePathT f String
addTrailingPathSeparator =
  (String -> String) -> ReadFilePathT f String
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String
FP.addTrailingPathSeparator

dropTrailingPathSeparator ::
  Applicative f =>
  ReadFilePathT f FilePath
dropTrailingPathSeparator :: ReadFilePathT f String
dropTrailingPathSeparator =
  (String -> String) -> ReadFilePathT f String
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String
FP.dropTrailingPathSeparator

normalise ::
  Applicative f =>
  ReadFilePathT f FilePath
normalise :: ReadFilePathT f String
normalise =
  (String -> String) -> ReadFilePathT f String
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String
FP.normalise

equalFilePath ::
  Applicative f =>
  ReadFilePathT f (FilePath -> Bool)
equalFilePath :: ReadFilePathT f (String -> Bool)
equalFilePath =
  (String -> String -> Bool) -> ReadFilePathT f (String -> Bool)
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String -> Bool
FP.equalFilePath

makeRelative ::
  Applicative f =>
  ReadFilePathT f (FilePath -> FilePath)
makeRelative :: ReadFilePathT f (String -> String)
makeRelative =
  (String -> String -> String) -> ReadFilePathT f (String -> String)
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String -> String
FP.makeRelative

isRelative ::
  Applicative f =>
  ReadFilePathT f Bool
isRelative :: ReadFilePathT f Bool
isRelative =
  (String -> Bool) -> ReadFilePathT f Bool
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> Bool
FP.isRelative

isAbsolute ::
  Applicative f =>
  ReadFilePathT f Bool
isAbsolute :: ReadFilePathT f Bool
isAbsolute =
  (String -> Bool) -> ReadFilePathT f Bool
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> Bool
FP.isAbsolute

isValid ::
  Applicative f =>
  ReadFilePathT f Bool
isValid :: ReadFilePathT f Bool
isValid =
  (String -> Bool) -> ReadFilePathT f Bool
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> Bool
FP.isValid

makeValid ::
  Applicative f =>
  ReadFilePathT f FilePath
makeValid :: ReadFilePathT f String
makeValid =
  (String -> String) -> ReadFilePathT f String
forall (f :: * -> *) a.
Applicative f =>
(String -> a) -> ReadFilePathT f a
liftReadFilePath String -> String
FP.makeValid