Use the template haskell (abbreviated to "TH") extension in a module with:
{-# LANGUAGE TemplateHaskell #-}There are a few key pieces of syntax:
| chris@precision:~/Work/chrisdone/prj$ stack build -v | |
| Version 2.2.0, Git revision 896869ee79d82e3bd9bead30d610ac2bf580cd99 (dirty) (7790 commits) PRE-RELEASE x86_64 hpack-0.31.2 | |
| 2019-07-31 13:32:31.396846: [debug] Checking for project config at: /home/chris/Work/chrisdone/prj/stack.yaml | |
| 2019-07-31 13:32:31.397084: [debug] Loading project config file stack.yaml | |
| 2019-07-31 13:32:31.405902: [debug] SELECT COUNT(*) FROM "last_performed" WHERE ("action"=?) AND ("timestamp">=?); [PersistInt64 1,PersistUTCTime 2019-07-30 12:32:31.40582 UTC] | |
| 2019-07-31 13:32:31.406606: [debug] Using package location completions from a lock file | |
| 2019-07-31 13:32:31.568532: [debug] Asking for a supported GHC version | |
| 2019-07-31 13:32:31.569087: [debug] Installed tools: | |
| - ghc-8.2.2 | |
| - ghc-8.6.3 |
| {- | |
| > :t $$(named [|| map ||]) | |
| $$(named [|| map ||]) | |
| :: TypedName | |
| ((ghc-prim-0.5.3:GHC.Types.Any -> ghc-prim-0.5.3:GHC.Types.Any) | |
| -> [ghc-prim-0.5.3:GHC.Types.Any] | |
| -> [ghc-prim-0.5.3:GHC.Types.Any]) | |
| > $$(named [|| map ||]) | |
| TypedName GHC.Base.map |
| {-# LANGUAGE DeriveDataTypeable #-} | |
| {-# LANGUAGE CPP #-} | |
| -- | A version of aeson that parses with key order preserved. | |
| -- | |
| -- Copyright: (c) 2019 Hasura, Inc. | |
| -- (c) 2011-2016 Bryan O'Sullivan | |
| -- (c) 2011 MailRank, Inc. | |
| module Data.Parser.Json |
| {-# OPTIONS_GHC -fno-warn-type-defaults #-} | |
| {-# LANGUAGE TypeFamilies #-} | |
| {-# LANGUAGE GADTs #-} | |
| {-# LANGUAGE ExtendedDefaultRules #-} | |
| {-# LANGUAGE LambdaCase #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| {-# LANGUAGE TypeApplications #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| {-# LANGUAGE ScopedTypeVariables #-} | |
| {-# LANGUAGE StandaloneDeriving #-} |
| $ stack exec maintainer | |
| Downloading https://api.github.com/user/repos?per_page=100&page=1 | |
| Downloading https://api.github.com/user/repos?per_page=100&page=2 | |
| Downloading https://api.github.com/user/repos?per_page=100&page=3 | |
| Downloading https://api.github.com/user/repos?per_page=100&page=4 | |
| Downloading https://api.github.com/user/repos?per_page=100&page=5 | |
| Downloading https://api.github.com/repos/haskell-perf/checklist/issues?state=open&sort=updated&direction=asc&per_page=100&page=1 | |
| Downloading https://api.github.com/repos/fpco/halogen-form/issues?state=open&sort=updated&direction=asc&per_page=100&page=1 | |
| Downloading https://api.github.com/repos/fpco/haskell.fpcomplete.com/issues?state=open&sort=updated&direction=asc&per_page=100&page=1 | |
| Downloading https://api.github.com/repos/fpco/odbc/issues?state=open&sort=updated&direction=asc&per_page=100&page=1 |
| (defvar server) | |
| (progn | |
| (delete-process server) | |
| (let ((coding-system-for-read 'binary)) | |
| (setq server | |
| (make-network-process | |
| :name "image-server" | |
| :buffer "*image-server*" | |
| :family 'ipv4 | |
| :service 9009 |
| (defvar server) | |
| (progn | |
| (delete-process server) | |
| (let ((coding-system-for-read 'binary)) | |
| (setq server | |
| (make-network-process | |
| :name "image-server" | |
| :buffer "*image-server*" | |
| :family 'ipv4 | |
| :service 9009 |
| {-# LANGUAGE BangPatterns #-} | |
| module Test (it) where | |
| it :: Int | |
| it = fibs Test.!! 49 | |
| fibs :: [Int] | |
| fibs = 1 : 1 : zipWith (+) fibs (tail fibs) |
| chris@precision:~/Work/chrisdone/prana/test-project$ stack build | |
| array-0.5.2.0: configure | |
| array-0.5.2.0: build | |
| array-0.5.2.0: copy/register | |
| test-project-0: configure (lib) | |
| Configuring test-project-0... | |
| test-project-0: build (lib) | |
| Preprocessing library for test-project-0.. | |
| Building library for test-project-0.. | |
| [1 of 1] Compiling Test ( Test.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Test.o ) |