{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
module Path.Like (
PathLike(..)
, FileLike(..)
, DirLike(..)
, (/>)
) where
import Path
class PathLike b t a | a -> b, a -> t where
toPath :: a -> Path b t
class PathLike b File a => FileLike b a where
toFile :: a -> Path b File
toFile = toPath
class PathLike b Dir a => DirLike b a where
toDir :: a -> Path b Dir
toDir = toPath
instance PathLike b t (Path b t) where
toPath = id
instance FileLike b (Path b File)
instance DirLike b (Path b Dir)
(/>) :: (DirLike b a, FileLike Rel c) => a -> c -> Path b File
(/>) x y = toDir x </> toFile y