Created
August 17, 2019 19:32
-
-
Save tydeu/9ecdf536ba397cd85215ca811525ca7c to your computer and use it in GitHub Desktop.
Rebindable Templates
This file contains 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 characters
import SpliceI | |
import SpliceS | |
main :: IO () | |
main = testI >> testS |
This file contains 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 characters
{-# LANGUAGE | |
TemplateHaskell | |
#-} | |
module Quote where | |
import Language.Haskell.TH | |
num :: Integer | |
num = 8 | |
magic :: Integer -> Q Exp | |
magic n = [| n |] | |
fromInteger :: Integer -> String | |
fromInteger = show |
This file contains 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 characters
{-# LANGUAGE | |
TemplateHaskell, RebindableSyntax | |
#-} | |
module SpliceI where | |
import Prelude | |
import Quote hiding (fromInteger) | |
testI :: IO () | |
testI = putStrLn $ show $(magic num) |
This file contains 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 characters
{-# LANGUAGE | |
TemplateHaskell, RebindableSyntax | |
#-} | |
module SpliceS where | |
import Prelude hiding (fromInteger) | |
import Quote | |
testS :: IO () | |
testS = putStrLn $ show $(magic num) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment