-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Quasiquoters for external commands -- -- Features: -- --
-- [sh| echo hello world! |] ---- --
-- ghci = QQ.quoter $ QQ.callCommand "ghc" ["-ignore-dot-ghci", "-e"] ---- --
-- class Embed a where -- embed :: a -> String -- -- instance Embed String -- embed = id -- -- main :: IO () -- main = let excl = replicate 3 '!' in -- I'd love to show an example but haddock markup fails here ---- --
-- class Eval r where -- eval :: String -> [String] -> r -- -- instance Eval (IO ExitCode) where -- eval command args = System.Process.rawSystem command args --@package command-qq @version 0.1.0.0 -- | Quasiquoters for external commands module System.Command.QQ -- | Quasiquoter for the default shell -- -- "default" here means it uses value of SHELL environment -- variable or /bin/sh if it is not set. -- --
-- >>> [sh|echo "hi!"|] :: IO ExitCode -- hi! -- ExitSuccess -- -- >>> [sh|echo "hi!"|] :: IO String -- "hi!\n" ---- -- Haskell values can be embedded with Ruby-like syntax: -- --
-- >>> let apples = 7
--
-- >>> [sh|echo "#{apples} apples!"|] :: IO String
-- "7 apples!\n"
--
--
-- Works only for expressions (obviously):
--
-- -- >>> return 3 :: IO [sh|blah|] -- -- <interactive>:116:16: -- Exception when trying to run compile-time code: -- this quasiquoter does not support splicing types -- Code: quoteType sh "blah" --sh :: QuasiQuoter -- | Shell commands quasiquoter maker -- -- "Shell" here means something that implements the following interface: -- --
-- <SHELL> -c <COMMAND> ---- -- e.g. sh, bash, zsh, ksh, -- tcsh, python, etc -- -- Everything that applies to sh applies to shell shell :: FilePath -> QuasiQuoter -- | Interpreter commands quasiquoter maker -- -- "Interpreter" here means something that implements the following -- interface: -- --
-- <INTERPRETER> -e <COMMAND> ---- -- e.g. perl, ruby, ghc, etc -- -- Everything that applies to sh applies to interpreter interpreter :: FilePath -> QuasiQuoter -- | Construct quasiquoter from function taking the string and producing -- Haskell expression. -- -- Other kinds of quasiquoters (patterns, types or declarations -- quasiquoters) will fail in compile time quoter :: (String -> Q Exp) -> QuasiQuoter -- | Construct Haskell expression for external command call callCommand :: FilePath -> [String] -> String -> Q Exp -- | Different interesting return types for quasiquoters -- -- Instances here mostly resemble the types of things in -- System.Process class Eval r eval :: Eval r => String -> [String] -> r -- | Embed haskell values into external commands -- -- I recommend using -XExtendedDefaultRules for modules where -- you want to embed values, it would save for annoying type annotations -- for numeric literals -- --
-- embed . embed = embed --class Embed a where embed = show embed :: Embed a => a -> String instance Embed String instance Embed Char instance Embed Double instance Embed Float instance Embed Word64 instance Embed Word32 instance Embed Word16 instance Embed Word8 instance Embed Word instance Embed Int64 instance Embed Int32 instance Embed Int16 instance Embed Int8 instance Embed Int instance Embed Integer instance (i ~ String, o ~ (ExitCode, String, String)) => Eval (i -> IO o) instance (s ~ ExitCode, o ~ String, e ~ String) => Eval (IO (s, o, e)) instance Eval (IO String) instance Eval (IO ExitCode) instance Eval (IO ())