Created
January 28, 2018 19:28
-
-
Save harpocrates/cfaf8c45092e17239d7cdcc172e90975 to your computer and use it in GitHub Desktop.
Multi-stage TH
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 characters
-- Notice how flipping the order of anything makes this not | |
-- compile - this demonstrates that GHC is doing the following | |
-- in order: | |
-- | |
-- 1. Processing the `foo` declaration | |
-- 2. Processing the `bar` declaration | |
-- 3. Processing the `baz` declaration | |
-- | |
-- So GHC is already doing multiple passes, right? | |
```haskell | |
{-# LANGUAGE TemplateHaskell, QuasiQuotes #-} | |
$([d| foo = (+1) |]) | |
bar = foo | |
$([d| baz = bar . (+2) |]) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment