@@ -68,6 +68,7 @@ module Data.Path.Pathy
68
68
import Data.Tuple (Tuple (..), fst , snd )
69
69
import Data.Either (Either (..), either )
70
70
import Data.Maybe (Maybe (..), maybe )
71
+ import Data.Bifunctor (bimap )
71
72
72
73
-- | The (phantom) type of relative paths.
73
74
foreign import data Rel :: *
@@ -95,7 +96,7 @@ module Data.Path.Pathy
95
96
runFileName (FileName name ) = name
96
97
97
98
-- | A newtype around a directory name.
98
- newtype DirName = DirName String
99
+ newtype DirName = DirName String
99
100
100
101
-- | Unwraps the `DirName` newtype.
101
102
runDirName :: DirName -> String
@@ -135,6 +136,15 @@ module Data.Path.Pathy
135
136
-- | A type describing a directory whose location is absolutely specified.
136
137
type AbsDir s = Path Abs Dir s
137
138
139
+ -- | A type describing a file or directory path.
140
+ type AnyPath b s = Either (Path b Dir s ) (Path b File s )
141
+
142
+ -- | A type describing a relative file or directory path.
143
+ type RelPath s = AnyPath Rel s
144
+
145
+ -- | A type describing an absolute file or directory path.
146
+ type AbsPath s = AnyPath Abs s
147
+
138
148
-- | Escapers encode segments or characters which have reserved meaning.
139
149
newtype Escaper = Escaper (String -> String )
140
150
@@ -199,6 +209,9 @@ module Data.Path.Pathy
199
209
(DirIn _ d ) -> Just d
200
210
_ -> Nothing
201
211
212
+ pathName :: forall b s. AnyPath b s -> Either (Maybe DirName ) FileName
213
+ pathName = bimap dirName fileName
214
+
202
215
infixl 6 </>
203
216
204
217
-- | Given a directory path, appends either a file or directory to the path.
0 commit comments