aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2024-03-09 16:11:26 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2024-03-12 02:29:37 +0100
commitaef8e4b26da7689ec03ad4a98ef94e833c363c29 (patch)
tree87ee9fff9daf64be8072ace7ae58c4a74222d68a
parent8b9a3b6ef6277a9e99961c62796d963dd88906a7 (diff)
chore: drop haskell-src-meta
-rw-r--r--sh.cabal1
-rw-r--r--src/Process/Shell.hs10
-rw-r--r--test/Main.hs8
3 files changed, 7 insertions, 12 deletions
diff --git a/sh.cabal b/sh.cabal
index da19b23..2c76f73 100644
--- a/sh.cabal
+++ b/sh.cabal
@@ -17,7 +17,6 @@ library
aeson,
base,
bytestring,
- haskell-src-meta,
megaparsec,
mtl,
template-haskell,
diff --git a/src/Process/Shell.hs b/src/Process/Shell.hs
index 41a15af..2542a2f 100644
--- a/src/Process/Shell.hs
+++ b/src/Process/Shell.hs
@@ -30,7 +30,6 @@ import Data.Text.Encoding qualified as T
import Data.Text.Lazy qualified as LT
import Data.Text.Lazy.Encoding qualified as LT
import Data.Void
-import Language.Haskell.Meta.Parse
import Language.Haskell.TH hiding (Type)
import Language.Haskell.TH.Quote
import System.Process.Typed
@@ -135,25 +134,26 @@ sh = QuasiQuoter quoteExp undefined undefined undefined
(,)
<$> ( many . choice . map try $
[ do
- Var False . either fail pure . parseExp
+ -- TODO Splice arbitrary Haskell expressions
+ Var False . varE . mkName
<$> ( string "#{{"
*> takeWhile1P Nothing (/= '}')
<* string "}}"
),
do
- Var True . either fail pure . parseExp
+ Var True . varE . mkName
<$> ( string "'#{{"
*> takeWhile1P Nothing (/= '}')
<* string "}}'"
),
do
- Var False . either fail (appE [|pure|] . pure) . parseExp
+ Var False . appE [|pure|] . varE . mkName
<$> ( string "#{"
*> takeWhile1P Nothing (/= '}')
<* string "}"
),
do
- Var True . either fail (appE [|pure|] . pure) . parseExp
+ Var True . appE [|pure|] . varE . mkName
<$> ( string "'#{"
*> takeWhile1P Nothing (/= '}')
<* string "}'"
diff --git a/test/Main.hs b/test/Main.hs
index 96612dc..2f20997 100644
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -1,10 +1,10 @@
{-# LANGUAGE BlockArguments #-}
+{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE QuasiQuotes #-}
module Main (main) where
-import Control.Monad.Reader
import Data.ByteString.Char8 qualified as B
import Data.ByteString.Lazy.Char8 qualified as LB
import Data.Text qualified as T
@@ -42,12 +42,8 @@ main = hspec do
it "passes `ByteString`" do
(`shouldBe` "foobar") =<< let x = B.pack "foobar" in [sh|echo '#{x}'|]
(`shouldBe` "foobar") =<< let x = LB.pack "foobar" in [sh|echo '#{x}'|]
- it "interpolates expressions" do
- (`shouldBe` "1") =<< let x = 1 :: Int in [sh|echo '#{show x}'|]
it "interpolates monadic expressions" do
- (`shouldBe` "1") =<< let x = 1 :: Int in [sh|echo '#{{pure @IO x}}'|]
- it "interpolates monadic expressions" do
- (`shouldBe` "1") =<< runReaderT [sh|echo '#{{asks fst}}'|] (1 :: Int, 2 :: Int)
+ (`shouldBe` "1") =<< let x = pure 1 :: IO Int in [sh|echo '#{{x}}'|]
it "preserves argument order" do
(`shouldBe` "1 2") =<< let x = "1"; y = "2" in [sh|echo '#{x}' '#{y}'|]
describe "quoting" do