blob: 487b5e4efceb20a2a54b9895411423a047597748 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
module Main where
import Language.Haskell.TH
import Language.Haskell.TH.Syntax (lift)
data family DF a
data instance DF [a] = DFList a
newtype instance DF (Maybe a) = DFMaybe a
$(return [])
main :: IO ()
main = print
$(do FamilyI (DataFamilyD _ _ _) insts <- reify ''DF
lift $ all (\case DataInstD _ _ [AppT _ (VarT v1)] _
[NormalC _ [(_, VarT v2)]] _
-> v1 == v2
NewtypeInstD _ _ [AppT _ (VarT v1)] _
(NormalC _ [(_, VarT v2)]) _
-> v1 == v2
_ -> error "Not a data or newtype instance")
insts)
|