command-qq-0.2.2.0: Quasiquoters for external commands

Safe HaskellNone
LanguageHaskell2010

System.Command.QQ

Contents

Description

Quasiquoters for external commands

Synopsis

Quasiquoters

Default shell

sh_ :: QuasiQuoter Source

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!

sh :: QuasiQuoter Source

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 -> QuasiQuoter Source

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 -> QuasiQuoter Source

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) -> QuasiQuoter Source

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

callCommand Source

Arguments

:: 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 Exp Source

Construct Haskell expression from the string, substituting variables for their values. Variable expansion uses a ruby-like syntax