Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Functions for checking different parameter/value combinations.
Synopsis
- eachFrom :: [a] -> Logic a
- getPVals :: [ParameterPattern] -> Logic [(String, Maybe String)]
- singlePVals :: [NamedParamMatch] -> [ParameterPattern] -> Logic [ParameterPattern]
- pvalMatch :: Separators -> [NamedParamMatch] -> [(String, Maybe String)] -> Logic ([NamedParamMatch], Int, String)
- removePVals :: [(String, a)] -> [(String, b)] -> [(String, a)]
- pmatchCmp :: [NamedParamMatch] -> [NamedParamMatch] -> Ordering
- pmatchMax :: (a -> [NamedParamMatch]) -> a -> a -> a
- dirMatches :: CandidateFile -> [ParameterPattern] -> [ParameterPattern] -> Logic ([NamedParamMatch], [ParameterPattern])
- inEachNothing :: Maybe a -> [(Maybe a, Bool, b)] -> Logic [(Maybe a, b)]
- isCompatible :: Separators -> [ParameterPattern] -> [(String, Maybe String)] -> CandidateFile -> Bool
Documentation
eachFrom :: [a] -> Logic a Source #
Core Logic function to iteratively return elements of a list via backtracking.
getPVals :: [ParameterPattern] -> Logic [(String, Maybe String)] Source #
Returns various combinations of parameter value selections
singlePVals :: [NamedParamMatch] -> [ParameterPattern] -> Logic [ParameterPattern] Source #
Returns a ParameterPattern admitting only a single value for each parameter, ensuring that the value is compatible with any existing NamedParamMatch. This is useful for callers wishing to handle each combination of parameter values separately.
pvalMatch :: Separators -> [NamedParamMatch] -> [(String, Maybe String)] -> Logic ([NamedParamMatch], Int, String) Source #
Generate each possible combination of Explicit or non-Explicit (Assumed or NotSpecified) parameter value and the corresponding string with each combination of separators. The string will be used to match against input files.
Note that valid combinations require that if a parameter is non-Explicit, all following parameters must also be non-Explicit.
The preset set of parameters are any parameters *already* matched against (usually in the rootName); these parameters may or may not be present in the filename matched from the output of this function, but if they are present, they must have the values specified in the preset (instead of having any of the possible values allowed for that parameter).
It's also possible that since this returns varying combinations of
parameters, that there may be multiple files that will match
against these combinations. Therefore, the results also indicate
how many of the parameters are used in the associated matching
string since the caller will usually select the match with the
highest ranking (number of matched parameters) in the filename.
[Note that it is not possibly to simply use the length of the
[NamedParamMatch]
return component since that may contain values
from the preset that don't actually occur in the match string.
removePVals :: [(String, a)] -> [(String, b)] -> [(String, a)] Source #
Removes the second set of named params from the first set, leaving the remainder of the first set that isn't matched in the second set.
pmatchCmp :: [NamedParamMatch] -> [NamedParamMatch] -> Ordering Source #
This provides an Ordering result of comparing two sets of NamedParamMatch. This can be used for sorting or other prioritization of named matches.
pmatchMax :: (a -> [NamedParamMatch]) -> a -> a -> a Source #
Returns the maximum of two arguments based on comparing the [NamedParamMatch] extracted from each argument (via the passed function).
dirMatches :: CandidateFile -> [ParameterPattern] -> [ParameterPattern] -> Logic ([NamedParamMatch], [ParameterPattern]) Source #
Given the root directory and a file in that directory, along with the possible parameters and values, return each valid set of parameter matches from that file, along with the remaining unmatched parameter possibilities.
The first set of parameters is the total set, and the second set represents those that could be identified in the path subdirs; this is needed to prevent a wildcard ParameterPattern in the second set from matching values explicit to other parameters.
inEachNothing :: Maybe a -> [(Maybe a, Bool, b)] -> Logic [(Maybe a, b)] Source #
Return each substitution of the first argument for each location in the second list that has a Nothing label and a True parameter; leave non-Nothings in the second list unchanged.
isCompatible :: Separators -> [ParameterPattern] -> [(String, Maybe String)] -> CandidateFile -> Bool Source #
isCompatible can be used as a filter predicate to determine if the specified file is compatible with the provided parameters and chosen parameter values. One principle compatibility check is ensuring that there is no *other* parameter value in the filename that conflicts with a chosen parameter value.