summaryrefslogtreecommitdiff
path: root/testsuite/tests/deSugar/should_compile/ds055.hs
blob: 280fe968d2c2c35b18571e487b84fd6b802be483 (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
29
30
{-# LANGUAGE ExistentialQuantification, DeriveDataTypeable #-}

-- This module requires quite trick desugaring,
-- because of the context in the existentials
-- It broke a pre 6.4 GHC

module Foo where

   import Data.Data
   import Data.HashTable

   data Item = forall a. (Data a) => Leaf Bool a
             | forall a. (Data a) => Branch Bool a Int Int
	     deriving (Typeable)


   instance Data Item where
       gfoldl k z (Leaf b v) = z (Leaf b) `k` v
       gfoldl k z (Branch b v a1 a2) = z (\x -> Branch b x a1 a2) `k` v
       gunfold _ _ _ = error "urk"
       toConstr (Leaf _ _) = leafConstr
       toConstr (Branch _ _ _ _) = branchConstr
       dataTypeOf _ = itemDataType

   itemDataType = mkDataType "Subliminal.Item" [leafConstr, branchConstr]
   leafConstr = mkConstr itemDataType "Leaf" [] Prefix
   branchConstr = mkConstr itemDataType "Branch" [] Prefix