file-command-qq

Quasiquoter for system commands involving filepaths

https://github.com/jfischoff/file-command-qq

Latest on Hackage:0.1.0.5

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

MIT licensed by Jonathan Fischoff
Maintained by [email protected]

file-command-qq is a simple quasiquoter for running system commands that take a filepath as an argument.

For instance

> :set -XOverloadedStrings
> import FileCommand
> import Filesystem.Path
> [s|echo $filename|] "/home/test/thing.txt"

will return

thing.txt
ExitSuccess

You can think of [s|echo $filename|] essentially converts into

\path -> system $ "echo" ++ encodeString (filename path)

Here is another example

> [s|gcc $path -o $directory$basename.o|] "/home/test/thing.c"

All "file parts" start with a '$'. The '$' can be escaped by preceding it with a '\'

There are the following options for "file parts"

  • $path

  • $root

  • $directory

  • $parent

  • $filename

  • $dirname

  • $basename

  • $ext

Which correspond to the respective functions in https://hackage.haskell.org/package/system-filepath-0.4.6/docs/Filesystem-Path.html#g:1