Module

Pathy.Name

#Name

newtype Name n

Constructors

Instances

#splitName

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

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

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

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

class IsName sym  where

Members

Instances

Modules