Last active
January 24, 2019 09:13
-
-
Save PkmX/1a78f337f3f82153755847e16e2bea94 to your computer and use it in GitHub Desktop.
Revisions
-
PkmX revised this gist
Jan 24, 2019 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ plugin = defaultPlugin parsedPlugin :: [CommandLineOption] -> ModSummary -> HsParsedModule -> Hsc HsParsedModule parsedPlugin _ _ HsParsedModule{..} = do let hpm_module' = SYB.mkT transform `SYB.everywhere` hpm_module return $ HsParsedModule{ hpm_module = hpm_module', .. } transform :: HsExpr GhcPs -> HsExpr GhcPs transform (HsLit _ (HsString _ fs)) = HsSpliceE NoExt $ mkHsQuasiQuote (mkVarUnqual "i") noSrcSpan fs This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ {-# OPTIONS_GHC -fplugin=Interpolate #-} module Main where -
PkmX revised this gist
Jan 24, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,4 +11,4 @@ s :: String s = "#{a} * #{a} = #{a * a}" main :: IO () main = putStrLn s -- 42 * 42 = 1764 -
PkmX created this gist
Jan 24, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} module Interpolate (plugin) where import GhcPlugins import HsSyn import qualified Data.Generics as SYB plugin :: Plugin plugin = defaultPlugin { parsedResultAction = parsedPlugin } parsedPlugin :: [CommandLineOption] -> ModSummary -> HsParsedModule -> Hsc HsParsedModule parsedPlugin _ _ HsParsedModule{..} = do let hpm_module' = SYB.mkT transform `SYB.everywhere` hpm_module return $ HsParsedModule{ hpm_module = hpm_module', ..} transform :: HsExpr GhcPs -> HsExpr GhcPs transform (HsLit _ (HsString _ fs)) = HsSpliceE NoExt $ mkHsQuasiQuote (mkVarUnqual "i") noSrcSpan fs transform expr = expr This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ {-# OPTIONS -fplugin=Interpolate #-} module Main where import Data.String.Interpolate a :: Int a = 42 s :: String s = "#{a} * #{a} = #{a * a}" main :: IO () main = putStrLn s