Fix QQ Text lifting error
Work around https://gitlab.haskell.org/ghc/ghc/-/issues/12596 using https://stackoverflow.com/questions/38143464/cant-find-inerface-file-declaration-for-variable
This commit is contained in:
parent
820499daff
commit
9920802798
|
@ -17,6 +17,7 @@ import qualified Data.Text as Text
|
||||||
import Data.List.NonEmpty ( NonEmpty(..) )
|
import Data.List.NonEmpty ( NonEmpty(..) )
|
||||||
import Data.Maybe ( mapMaybe )
|
import Data.Maybe ( mapMaybe )
|
||||||
import Language.Haskell.TH
|
import Language.Haskell.TH
|
||||||
|
import Language.Haskell.TH.Syntax ( liftString )
|
||||||
import Language.Haskell.TH.Quote
|
import Language.Haskell.TH.Quote
|
||||||
import Nix.Atoms
|
import Nix.Atoms
|
||||||
import Nix.Expr
|
import Nix.Expr
|
||||||
|
@ -27,7 +28,12 @@ quoteExprExp s = do
|
||||||
expr <- case parseNixText (Text.pack s) of
|
expr <- case parseNixText (Text.pack s) of
|
||||||
Failure err -> fail $ show err
|
Failure err -> fail $ show err
|
||||||
Success e -> pure e
|
Success e -> pure e
|
||||||
dataToExpQ (const Nothing `extQ` metaExp (freeVars expr)) expr
|
dataToExpQ
|
||||||
|
(const Nothing `extQ` metaExp (freeVars expr) `extQ` (Just . liftText))
|
||||||
|
expr
|
||||||
|
where
|
||||||
|
liftText :: Text.Text -> Q Exp
|
||||||
|
liftText txt = AppE (VarE 'Text.pack) <$> liftString (Text.unpack txt)
|
||||||
|
|
||||||
quoteExprPat :: String -> PatQ
|
quoteExprPat :: String -> PatQ
|
||||||
quoteExprPat s = do
|
quoteExprPat s = do
|
||||||
|
|
Loading…
Reference in New Issue