summaryrefslogtreecommitdiff
path: root/testsuite/tests/simplCore/should_compile/T2520.hs
blob: f0115474ea665c4e63d9c5a2fce39aa56bad9529 (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
26
27
28
{-# LANGUAGE GADTs #-}

-- Trac #2520: a bug in the specialiser when we tried to
-- quantify over an Internal Name

module Types where

data Prod a b = Prod a b

data Nil = Nil

class ProdSel f where
   nil :: f Nil
   prod :: f x -> f y -> f (Prod x y)

instance ProdSel SqlFields where
   nil = SFNil
   prod = SFProd

{-# SPECIALIZE reproject :: SqlFields a -> SqlFields a #-}

reproject :: ProdSel f => SqlFields a -> f a
reproject SFNil = nil
reproject (SFProd a b) = prod (reproject a) (reproject b)

data SqlFields a where
  SFNil :: SqlFields Nil
  SFProd :: SqlFields a -> SqlFields b -> SqlFields (Prod a b)