Skip to content

A type for filepath components #234

@mmhat

Description

@mmhat

While working on commercialhaskell/path#192 I noted that it might be helpful to have a separate type for a path component for some use cases. Since we have the nice AFPP-style APIs that is nothing more than a slice of the underlying filepath:

module System.OsPath.Component where

-- | A component of a filepath, i.e. a filpath that does not contain any path separators.
newtype Component = Component (SliceOf OsPath)

-- This should probably live in the os-string package
data SliceOf = SliceOf
  { sliceOfOffset :: {-# UNPACK #-} Int -- ^ The offset where the slice starts in bytes
  , sliceOfLength :: {-# UNPACK #-} Int -- ^ The length of the slice in bytes
  , sliceOfFilePath :: {-# UNPACK #-} OsPath -- ^ The underlying filepath
  }

As far as I am concerned I am only interested in an addition for the AFPP-style filepaths.

Would the contribution of such a type and the API for working with it accepted?
Is a CLC proposal needed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions