New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expose Development.Shake.FilePattern.match or similar #485
Comments
That does sound like quite a reasonable idea - only hard bit is figuring out exactly what the API should be. Does it deserve a symbol? I suspect so. Should the full path be the first component of the array? Is |
Empirically, I've found it quite useful to include it: if it is not included, and the action you want to run needs to know it (e.g. for the argument to
I think checking this statically would require some fairly heavyweight infrastructure for a smallish benefit, especially considering how easy it is to notice that you got it wrong when testing the new rule you just wrote. You could also look to the various regex libraries, which also do the statically unsafe thing and return a For posterity, I implemented a similar function using regex-tdfa like this and have found it quite useful; the only change to the API I suggested above is that my action takes the full filename as a separate argument:
|
Oh yes, and I forgot to include the definition of
...but that's a separate feature request. ;-) |
The new Shake has |
See https://hackage.haskell.org/package/filepattern which now offers a complete API. |
I want to write a rule like this:
where here if the matching file were, say,
build/year-2016-loc-OR.json
, the variablesyear
andloc
would get bound to"2016"
and"OR"
, respectively. I could imagine wanting to know which part of the filename the//
and**
globs matched as well, of course. Perhaps a slightly higher-level API would also be welcome, e.g. something likeso that the above rule could also be written:
The text was updated successfully, but these errors were encountered: