Copyright | (C) Richard Cook 2017-2018 |
---|---|
License | MIT |
Maintainer | rcook@rcook.org |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
- readApp :: UpdateContext -> [Tool] -> FilePath -> IO (Either String App)
- runTool :: RunContext -> Tool -> IO ()
- data App = App [Route] [Target]
- type FilePathResolver = FilePath -> FilePath
- data Route = Route [String] FilePath
- data RunContext = RunContext FilePath [FilePath] [FilePath]
- data Target = Target PathPattern Tool [PathPattern] [PathPattern]
- data Tool = Tool String (UpdateContext -> Value -> Parser Tool) (RunContext -> IO ())
- data UpdateContext = UpdateContext FilePathResolver
- splitRoutePath :: String -> [String]
- data PathPattern
- pathPattern :: String -> Either String PathPattern
- pathPatternStem :: PathPattern -> FilePath -> String
- substituteStem :: String -> PathPattern -> FilePath
- (%%>>) :: PathPattern -> (FilePath -> Action ()) -> Rules ()
- countOccurrences :: String -> String -> Int
- stems :: Eq a => [a] -> [a] -> ([a], [a])
Documentation
type FilePathResolver = FilePath -> FilePath Source #
data RunContext Source #
splitRoutePath :: String -> [String] Source #
Split route path into fragments
Examples:
>>>
splitRoutePath "aaa/bbb"
["aaa","bbb"]>>>
splitRoutePath "aaa"
["aaa"]>>>
splitRoutePath ""
[]
data PathPattern Source #
pathPattern :: String -> Either String PathPattern Source #
Convert string to path pattern
Examples:
>>>
import Data.Either
>>>
isRight $ pathPattern "%"
True>>>
isRight $ pathPattern "aaa"
True>>>
isLeft $ pathPattern "%%"
True>>>
isLeft $ pathPattern "%aaa%"
True
pathPatternStem :: PathPattern -> FilePath -> String Source #
Stem of pattern and path
Examples:
>>>
Right p = pathPattern "C:/aaa/bbb/%.txt"
>>>
pathPatternStem p "C:/aaa/bbb/stem.txt"
"stem"
substituteStem :: String -> PathPattern -> FilePath Source #
Substitute stem in path pattern
Examples:
>>>
Right p = pathPattern "/aaa/bbb/%/ddd/eee/"
>>>
substituteStem "ccc" p
"/aaa/bbb/ccc/ddd/eee/"
countOccurrences :: String -> String -> Int Source #
Number of occurrences of a substring in a string
Examples:
>>>
countOccurrences "" "abc"
0>>>
countOccurrences "" ""
0>>>
countOccurrences "abcdefghi" "xyz"
0>>>
countOccurrences "abc" "abc"
1>>>
countOccurrences "abcabc" "abc"
2>>>
countOccurrences "abcdefabcghiabcjkl" "abc"
3