Template Haskell はHaskellの言語仕様には無くGHCの独自拡張なのでGHCのバージョンが変わる毎に仕様も変わる可能性があるので注意
- A Brief Introduction to Template Haskell
- 7.17. Template Haskell
- Template Haskell Is Not Scary
- Template Haskell
- Language.Haskell.TH
- できる!Template Haskell (完)
- TemplateHaskellでコンパイル時に計算しておく方法
- Typed holes support in Template Haskell
- 24 days of Hackage, 2015: day 9: Template Haskell goodies: here, interpolate, file-embed
- User-defined literals in Haskell via QuasiQuotes
- What Template Haskell gets wrong and Racket gets right
- functor.tokyo – Inspecting generated Template Haskell
- Template Haskellを使って定数をコンパイル時に計算しておく - Qiita
- Quasiquotes and Template Haskell | Py Py Python
- maxigit/Metamorphosis: TemplateHaskell functions to generate types and converter function.
- Template Haskell – zw3rk – Medium
- Bloggy Badger: Composing Declarations in Template Haskell
- Template Haskell tutorial
- Haskellで手軽に変数を文字列に埋め込む - 変数展開 - Qiita
- Template Haskell でコンパイル時 FizzBuzz
- Template Haskell でコード中に JSON を埋め込んだりコンパイル時にファイルから型安全に読み込んだりする
- Haskellの実行バイナリにファイルを埋め込む - syocy’s diary
- 任意の関数をTemplateHaskellでコンパイル時に実行して安全性を確保する - Qiita
- mpickering - Source Plugins: Four ways to build a typechecked Haskell expression
- Template Haskellでコンパイル時にFizzBuzz - Qiita
- Fast file embedding with GHC!
- Static Smart Constructors with Double Splices
- Oleg’s gists - Compiling Haskell to JavaScript, not in the way you’d expect
- dfithian/th-workshop: Template Haskell Workshop
- Well-Typed - The Haskell Consultants: Using Template Haskell to generate static data
- Tweag - A tale of Template Haskell and cross compilation
- Haskell doesn’t have macros
- Tweag - Haskell dark arts, part I: importing hidden values
- Template Haskell Performance Tips
- A Short Overview of Typed Template Haskell
- A tale of Template Haskell and cross compilation - Tweag
{-# LANGUAGE QuasiQuotes #-}
import Language.Haskell.TH.Quote
readCSV xs = let (ys, zs) = break (==',') xs
in if null zs then [ys]
else ys : readCSV (tail zs)
csv :: QuasiQuoter
csv = QuasiQuoter
{ quoteExp = exp
, quotePat = undefined
, quoteType = undefined
, quoteDec = undefined
}
where
exp = dataToExpQ (const Nothing) . readCSV
>>> [csv|1,2,3|]
["1","2","3"]