Skip to content

Instantly share code, notes, and snippets.

@Profpatsch
Created December 5, 2017 09:47
Show Gist options
  • Save Profpatsch/03f97fd8b6f73d5fa279dc869b44844f to your computer and use it in GitHub Desktop.
Save Profpatsch/03f97fd8b6f73d5fa279dc869b44844f to your computer and use it in GitHub Desktop.
Abstraction in Shake
main = do
let buildDir = "_build"
-- how to express on a non-string level that everything should only ever be put into "_build"?
-- how to never repeat that information anywhere else, much less do problematic string operations
-- with the `"_build"` constant?
staticDir = "static"
staticFiles = map (staticDir <>) [ "foo" "bar" "baz" ]
(buildDir </> staticDir </> "*") %> \outFile ->
-- we only get `out`, which is some unknown string
-- so: how to recover the semantic information where to find the static file?
let inFile = magicallyAndManuallyStriptheBuildDirAgain outFile
copyFile inFile outFile
-- another thing:
-- No separation between build inputs and mutated files
phony "clean, maybe?" $ do
removeFiles "foo"
-- oops, of course should have been `buildDir </> "foo"`.
-- ah, well, who needed those source files anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment