summaryrefslogtreecommitdiff
path: root/testsuite/tests/th/TH_overloadedlabels.hs
blob: d45a2f192cae7ee15f1e06fa1100df368930d99f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module TH_overloadedlabels where

import Language.Haskell.TH
import GHC.OverloadedLabels

data T = T { sel :: Int}

instance IsLabel "sel" (T -> Int) where
  fromLabel (T n) = n

x :: Int
x = $(labelE "sel") (T 5)

y :: Int
y = $( [| #sel |] ) (T 6)