{-# LANGUAGE CPP #-}

module Path.Extended 
 ( fileExtension
 , addExtension
 , replaceExtension
 ) where

import           Control.Monad.Catch
import qualified Path
import           Path (Path, File)

fileExtension :: MonadThrow m => Path b File -> m String
fileExtension :: Path b File -> m String
fileExtension = 
#if MIN_VERSION_path(0,7,0)
    Path b File -> m String
forall (m :: * -> *) b. MonadThrow m => Path b File -> m String
Path.fileExtension
#else
    pure . Path.fileExtension
#endif

addExtension :: MonadThrow m
  => String
  -> Path b File
  -> m (Path b File)
addExtension :: String -> Path b File -> m (Path b File)
addExtension =
#if MIN_VERSION_path(0,7,0)
    String -> Path b File -> m (Path b File)
forall (m :: * -> *) b.
MonadThrow m =>
String -> Path b File -> m (Path b File)
Path.addExtension
#else
    Path.addFileExtension
#endif

replaceExtension :: MonadThrow m
  => String
  -> Path b File
  -> m (Path b File)
#if MIN_VERSION_path(0,7,0)
replaceExtension :: String -> Path b File -> m (Path b File)
replaceExtension String
ext = String -> Path b File -> m (Path b File)
forall (m :: * -> *) b.
MonadThrow m =>
String -> Path b File -> m (Path b File)
Path.replaceExtension (Char
'.' Char -> String -> String
forall a. a -> [a] -> [a]
: String
ext)
#else
replaceExtension = flip (Path.-<.>)
#endif