module Path where

import           Imports

import           System.FilePath

fromFilePath :: FilePath -> Path
fromFilePath :: FilePath -> Path
fromFilePath = [PathComponent] -> Path
Path forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map FilePath -> PathComponent
PathComponent forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> [FilePath]
splitDirectories

toFilePath :: Path -> FilePath
toFilePath :: Path -> FilePath
toFilePath = [FilePath] -> FilePath
joinPath forall b c a. (b -> c) -> (a -> b) -> a -> c
. Path -> [FilePath]
components

components :: Path -> [String]
components :: Path -> [FilePath]
components = forall a b. (a -> b) -> [a] -> [b]
map PathComponent -> FilePath
unPathComponent forall b c a. (b -> c) -> (a -> b) -> a -> c
. Path -> [PathComponent]
unPath

newtype Path = Path {Path -> [PathComponent]
unPath :: [PathComponent]}
  deriving Path -> Path -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Path -> Path -> Bool
$c/= :: Path -> Path -> Bool
== :: Path -> Path -> Bool
$c== :: Path -> Path -> Bool
Eq

instance Show Path where
  show :: Path -> FilePath
show = forall a. Show a => a -> FilePath
show forall b c a. (b -> c) -> (a -> b) -> a -> c
. Path -> FilePath
toFilePath

instance IsString Path where
  fromString :: FilePath -> Path
fromString = FilePath -> Path
fromFilePath

newtype PathComponent = PathComponent {PathComponent -> FilePath
unPathComponent :: String}
  deriving PathComponent -> PathComponent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PathComponent -> PathComponent -> Bool
$c/= :: PathComponent -> PathComponent -> Bool
== :: PathComponent -> PathComponent -> Bool
$c== :: PathComponent -> PathComponent -> Bool
Eq