@hackage command-qq0.3.1.0
Quasiquoters for external commands
Categories
License
BSD-2-Clause
Maintainer
matvey.aksenov@gmail.com
Links
Versions
Installation
Dependencies (4)
- base >=4 && <5
- process
- template-haskell
- text Show all…
Dependents (3)
@hackage/acme-everything, @hackage/coformat, @hackage/directory-layout
command-qq
>>> import System.Command.QQ
>>> putStr =<< unlines . reverse . lines <$> [sh|cowsay "Hello, I am command-qq!"|]
|| ||
||----w |
(__)\ )\/\
\ (oo)\_______
\ ^__^
-------------------------
< Hello, I am command-qq! >
_________________________
Install
% cabal install command-qq
Features
Quasiquotation syntax for external interpreters
>>> [sh_| echo hello world! |]
hello world!
Custom quasiquoters
ghci = quoter $ callCommand "ghc" ["-ignore-dot-ghci", "-e"]
Then you can use ghci in ghci!
>>> [ghci| putStrLn "hello world!" |] :: IO ()
hello world!
For more examples, see System.Command.QQ.Predef
Haskell values embedding
Let's define Embed instance for a custom data type:
data Bang = Bang
instance Embed Bang where
embed Bang = "!"
Then you can use variables of Bang type in quoted strings!
>>> [sh_| echo hello#{Bang} |]
hello!
>>> let bang = Bang in [sh_| echo hello#{bang} |]
hello!
Note, command-qq does not support full Haskell in embeddings,
only variables/constructors names and literals

