summaryrefslogtreecommitdiff
path: root/testsuite/tests/th/overloaded/TH_overloaded_extract.hs
blob: 23c5ac5257bd781e783b107f7c78be3a8d769213 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE TemplateHaskell #-}
module Main where
-- A simple test to check that defining a custom instance is easily
-- possible and extraction works as expected.

import Language.Haskell.TH
import Language.Haskell.TH.Syntax
import Data.Functor.Identity


instance Quote Identity where
  -- Not the correct implementation, just for testing
  newName s = Identity (Name (mkOccName s) NameS)

main = do
  print $ runIdentity [| 1 + 2 |]
  print $ runIdentity [| \x -> 1 + 2 |]
  print $ runIdentity [d| data Foo = Foo |]
  print $ runIdentity [p| () |]
  print $ runIdentity [t| [Int] |]
  print $ unType $ runIdentity [|| (+1) ||]