aboutsummaryrefslogtreecommitdiffstats
path: root/src/Process
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2024-03-07 05:19:24 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2024-03-07 05:19:27 +0100
commit3c8288e53347b90968abe5afcb1addf3bea5e00e (patch)
tree5cb0b2ead586f71a24e5ec30ed6fa842cb375729 /src/Process
parent026f5b8786fece894ab1357747627b180db5a0ee (diff)
chore: simplify quasi quoter implementation
Diffstat (limited to 'src/Process')
-rw-r--r--src/Process/Shell.hs14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/Process/Shell.hs b/src/Process/Shell.hs
index 2d254ad..10b85b5 100644
--- a/src/Process/Shell.hs
+++ b/src/Process/Shell.hs
@@ -144,12 +144,8 @@ sh = QuasiQuoter quoteExp undefined undefined undefined
Lit <$> takeWhile1P Nothing ((&&) <$> (/= '#') <*> (/= '\''))
]
- makeExp :: [Expr] -> Q Exp
- makeExp exprs = do
- appE [|sh_|] $ flip (foldM (flip go)) exprs =<< [|""|]
-
- go (Lit s) = appE [|flip (++) s|] . pure
- go (Var q exp) =
- appE
- (appE [|flip (++)|] (appE [|if q then squote else dquote|] exp))
- . pure
+ makeExp exprs =
+ [|sh_ $(foldr (\a b -> [|$a ++ $b|]) [|""|] (map toExp exprs))|]
+
+ toExp (Lit s) = [|s|]
+ toExp (Var q exp) = [|(if q then squote else dquote) $exp|]