Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add commonly used synonyms, pathName #15

Merged
merged 1 commit into from
Apr 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/Data/Path/Pathy.purs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ module Data.Path.Pathy
import Data.Tuple(Tuple(..), fst, snd)
import Data.Either(Either(..), either)
import Data.Maybe(Maybe(..), maybe)
import Data.Bifunctor(bimap)

-- | The (phantom) type of relative paths.
foreign import data Rel :: *
Expand Down Expand Up @@ -95,7 +96,7 @@ module Data.Path.Pathy
runFileName (FileName name) = name

-- | A newtype around a directory name.
newtype DirName = DirName String
newtype DirName = DirName String

-- | Unwraps the `DirName` newtype.
runDirName :: DirName -> String
Expand Down Expand Up @@ -135,6 +136,15 @@ module Data.Path.Pathy
-- | A type describing a directory whose location is absolutely specified.
type AbsDir s = Path Abs Dir s

-- | A type describing a file or directory path.
type AnyPath b s = Either (Path b Dir s) (Path b File s)

-- | A type describing a relative file or directory path.
type RelPath s = AnyPath Rel s

-- | A type describing an absolute file or directory path.
type AbsPath s = AnyPath Abs s

-- | Escapers encode segments or characters which have reserved meaning.
newtype Escaper = Escaper (String -> String)

Expand Down Expand Up @@ -199,6 +209,9 @@ module Data.Path.Pathy
(DirIn _ d) -> Just d
_ -> Nothing

pathName :: forall b s. AnyPath b s -> Either (Maybe DirName) FileName
pathName = bimap dirName fileName
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should just be name? Wasn't sure...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for pathName

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for pathName


infixl 6 </>

-- | Given a directory path, appends either a file or directory to the path.
Expand Down