Safe Haskell | None |
---|
Quasiquoters for external commands
- sh_ :: QuasiQuoter
- sh :: QuasiQuoter
- shell :: FilePath -> QuasiQuoter
- interpreter :: FilePath -> QuasiQuoter
- quoter :: (String -> Q Exp) -> QuasiQuoter
- callCommand :: FilePath -> [String] -> String -> Q Exp
- substituteVars :: String -> Q Exp
- module System.Command.QQ.Embed
- module System.Command.QQ.Eval
Quasiquoters
Default shell
Simple quasiquoter for the default shell
sh
analog that always constructs an action of type
IO ()
and so can always be used without type annotations
>>>
[sh_|echo "hello, world!"|]
hello, world!
Quasiquoter for the default shell
Constructs polymorphic action of type Eval a => a
from passed string.
Uses SHELL
environment variable as path to shell executable
or /bin/sh
if it is unset.
>>>
[sh|echo "hello, world!"|] :: IO ExitCode
ExitSuccess>>>
[sh|echo "hello, world!"|] :: IO Text
"hello, world!\n"
Haskell values can be embedded with Ruby-like syntax:
>>>
let apples = 7
>>>
[sh|echo "#{apples} apples!"|] :: IO Text
"7 apples!\n"
Constructors
shell :: FilePath -> QuasiQuoterSource
Shell's quasiquoter constructor
"Shell" here means executable that has the following API:
<SHELL> -c <COMMAND>
e.g. sh
, bash
, zsh
, ksh
, tcsh
, python
, etc
interpreter :: FilePath -> QuasiQuoterSource
Interpreter's quasiquoter constructor
"Interpreter" here means executable that has the following API:
<INTERPRETER> -e <COMMAND>
e.g. perl
, ruby
, ghc
, etc
Customizations
quoter :: (String -> Q Exp) -> QuasiQuoterSource
Construct quasiquoter from function taking the string and producing Haskell expression.
Other kinds of quasiquoters (patterns, types or declarations quasiquoters) will fail at compile time
:: FilePath | Command path |
-> [String] | Arguments that go to command before quasiquoter contents |
-> String | Quasiquoter contents |
-> Q Exp |
Construct Haskell expression for external command call
substituteVars :: String -> Q ExpSource
Construct Haskell expression from the string, substituting variables for their values. Variable expansion uses a ruby-like syntax
module System.Command.QQ.Embed
module System.Command.QQ.Eval