dojang-0.2.1: A cross-platform dotfiles manager
Safe HaskellNone
LanguageHaskell2010

Dojang.Types.Context

Synopsis

Documentation

data CandidateRoute Source #

A candidate route with computed metadata for disambiguation.

Constructors

CandidateRoute 

Fields

  • route :: RouteResult

    The route result.

  • specificity :: Int

    The specificity of the route, i.e., the number of path components from the route's destination to the target path. Lower is more specific.

  • sourceFilePath :: OsPath

    The computed source file path (combining route source path with relative path from destination to target).

  • sourceExists :: Bool

    Whether the source file for this route already exists.

Instances

Instances details
Show CandidateRoute Source # 
Instance details

Defined in Dojang.Types.Context

Eq CandidateRoute Source # 
Instance details

Defined in Dojang.Types.Context

data MonadFileSystem m => Context (m :: Type -> Type) Source #

The context in which repository operations are performed.

Constructors

Context 

Fields

data FileCorrespondence Source #

A correspondence between a source file, an intermediate file, and a destination file.

Constructors

FileCorrespondence 

Fields

data FileEntry Source #

A file/directory in the repository or the destination directory.

Constructors

FileEntry 

Fields

Instances

Instances details
Show FileEntry Source # 
Instance details

Defined in Dojang.Types.Context

Eq FileEntry Source # 
Instance details

Defined in Dojang.Types.Context

Ord FileEntry Source # 
Instance details

Defined in Dojang.Types.Context

data FileStat Source #

The small stat of a file.

Constructors

Missing

The file is missing.

Directory

The file is a directory.

File Integer

The file is a regular file, and this is its size in bytes.

Symlink OsPath

The file is a symlink, and this is the path to the symlink target.

Instances

Instances details
Show FileStat Source # 
Instance details

Defined in Dojang.Types.Context

Eq FileStat Source # 
Instance details

Defined in Dojang.Types.Context

Ord FileStat Source # 
Instance details

Defined in Dojang.Types.Context

data IgnoredFile Source #

Represents a file that is ignored by a route's ignore patterns.

Constructors

IgnoredFile 

Fields

Instances

Instances details
Show IgnoredFile Source # 
Instance details

Defined in Dojang.Types.Context

Eq IgnoredFile Source # 
Instance details

Defined in Dojang.Types.Context

data RouteMatch Source #

Result of finding routes for a destination path.

Constructors

NoMatch

No matching routes found.

SingleMatch RouteResult

A single unambiguous route was found.

AmbiguousMatch (NonEmpty CandidateRoute)

Multiple routes match with the same specificity.

Instances

Instances details
Show RouteMatch Source # 
Instance details

Defined in Dojang.Types.Context

Eq RouteMatch Source # 
Instance details

Defined in Dojang.Types.Context

data RouteState Source #

Represents the route state of a (potential) destination file in the repository.

Constructors

Routed OsPath

The file is routed. The OsPath is the name of the relevant route name.

Ignored OsPath FilePattern

The file is routed but ignored. The OsPath is the name of the relevant route name, and the FilePattern is the ignore pattern that matched the file.

NotRouted

The file is not routed at all.

data UnregisteredFile Source #

Represents a file that is not registered in any route.

Constructors

UnregisteredFile 

Fields

calculateSpecificity Source #

Arguments

:: OsPath

The target path.

-> RouteResult

The route result.

-> Int

The specificity (number of path components from route destination to target).

Calculate the specificity of a route relative to a target path. Returns the number of path components between the route's destination and the target path. Lower values indicate more specific routes.

Examples

>>> calculateSpecificity "/foo/bar/baz" route  -- route.destinationPath = "/foo"
2  -- bar/baz
>>> calculateSpecificity "/foo" route  -- route.destinationPath = "/foo"
0  -- exact match

filterBySpecificity Source #

Arguments

:: OsPath

The target path.

-> [RouteResult]

The list of routes to filter.

-> [RouteResult]

The routes with the lowest specificity.

Filter routes by specificity, keeping only those with the lowest (most specific) specificity value.

findCandidateRoutesFor Source #

Arguments

:: MonadFileSystem m 
=> Context m

The context in which to perform the operation.

-> OsPath

The path to the unregistered file.

-> m [RouteResult]

The list of candidate routes.

Finds candidate routes for an unregistered file. Returns routes whose destination path is a prefix of the file path.

findMatchingRoutes Source #

Arguments

:: MonadFileSystem m 
=> Context m

The context in which to perform route matching.

-> OsPath

The target path.

-> m (RouteMatch, [RouteMapWarning])

The route match result, along with any warnings that were generated.

Find matching routes for a destination path. Returns a RouteMatch indicating whether no routes, a single route, or multiple ambiguous routes match.

getIgnoredFiles Source #

Arguments

:: (HasCallStack, MonadFileSystem m) 
=> Context m

The context in which to perform the operation.

-> m [IgnoredFile]

The list of ignored files.

Gets a list of files that are ignored by the repository's ignore patterns. This function scans all directory routes for files that would be excluded by their ignore patterns.

getRouteState Source #

Arguments

:: (HasCallStack, MonadFileSystem m, MonadIO m) 
=> Context m

The context in which to perform path routing.

-> OsPath

The path (which is a potential destination) to get the route state of.

-> m (RouteState, [RouteMapWarning])

The route state of the path, along with any warnings that were generated.

Gets the route state of the given path (which is a potential destination).

getUnregisteredFiles Source #

Arguments

:: (HasCallStack, MonadFileSystem m) 
=> Context m

The context in which to perform the operation.

-> m [UnregisteredFile]

The list of unregistered files.

Gets a list of files in destination directories that are not registered in any route. These are files that exist in destination directories but are not part of the repository.

listFiles Source #

Arguments

:: MonadFileSystem m 
=> OsPath

The path to the directory to list entries in.

-> [FilePattern]

The file patterns to ignore. If a directory matches one of these patterns, then its contents will not be listed either.

-> m [FileEntry]

The list of FileEntry values in the directory.

Lists all FilEntry values in the given directory. Throws an IOError if the directory cannot be read.

makeCorrespond Source #

Arguments

:: (HasCallStack, MonadFileSystem m) 
=> Context m

The context in which to perform file correspondence.

-> m ([FileCorrespondence], [RouteMapWarning])

The file correspondences, along with a list of warnings that occurred during path routing (if any). The file paths in the returned FileCorrespondence values are absolute, or relative to the current working directory at least.

Creates a list of file correspondences between the source files, the intermediate files, and the destination files. Throws an IOError if any of the files cannot be read.

makeCorrespondWithDestination Source #

Arguments

:: MonadFileSystem m 
=> Context m

The context in which to perform file correspondence.

-> OsPath

The path to the destination file.

-> m (Maybe FileCorrespondence, [RouteMapWarning])

The file correspondence, along with a list of warnings that occurred during path routing (if any). The file paths in the returned FileCorrespondence value are absolute, or relative to the current working directory at least.

Creates a FileCorrespondence from a single destination file.

routePaths Source #

Arguments

:: MonadFileSystem m 
=> Context m

The context in which to perform path routing.

-> m ([RouteResult], [RouteMapWarning])

The expanded paths, along with any warnings that were generated.

Route the paths in the repository. This will return a list of expanded paths, along with any warnings that were generated. Null routes will be ignored.