Pathy.Name
- Package
- purescript-pathy
- Repository
- purescript-contrib/purescript-pathy
#splitName Source
splitName :: forall n. Name n -> { ext :: Maybe NonEmptyString, name :: NonEmptyString }
Splits Name
in name and extension part.
splitName (Name ".foo") == { name: ".foo", extension: Nothing }
splitName (Name "foo.") == { name: "foo.", extension: Nothing }
splitName (Name "foo") == { name: "foo", extension: Nothing }
splitName (Name ".") == { name: ".", extension: Nothing }
splitName (Name "foo.baz") == { name: "foo", extension: Just "baz" }
Note, in real code all strings from this examples would be NonEmptyString
.
Also for any Name
this property holds:
joinName <<< splitName = id
see joinName
.
#joinName Source
joinName :: forall n. { ext :: Maybe NonEmptyString, name :: NonEmptyString } -> Name n
Joins name and extension part into one Name
.
Also for any Name
this property holds:
joinName <<< splitName = id
see splitName
.
#extension Source
extension :: forall n. Name n -> Maybe NonEmptyString
Retrieves the extension of a name. also see splitName
extension (Name ".foo") == Nothing
extension (Name "foo.") == Nothing
extension (Name ".") == Nothing
extension (Name "foo.baz") == Just "baz"
Note, in real code all strings from this examples would be NonEmptyString
.
#alterExtension Source
alterExtension :: forall n. (Maybe NonEmptyString -> Maybe NonEmptyString) -> Name n -> Name n
Alters an extension of a name. This allows extensions to be added, removed,
or modified. see splitName
and joinName
for how a Name
is split into name and extention part and joined back
into a Name
.
Also for any Name
this property holds:
alterExtension id = id
#IsName Source
class IsName :: Symbol -> Constraint
class IsName sym where
A class for creating Name
values from type-level strings. This allows us
to guarantee that a name is not empty at compile-time.
Members
reflectName :: forall proxy d. proxy sym -> Name d