Commit a8245005 authored by simonpj's avatar simonpj
Browse files

[project @ 2005-03-01 05:48:11 by simonpj]

Add a desugaring test involving existentials
parent a766958a
......@@ -58,3 +58,4 @@ test('ds051', normal, compile, [''])
test('ds052', expect_fail_if_compiler_type('ghc'), compile, [''])
test('ds053', normal, compile, [''])
test('ds054', normal, compile, [''])
test('ds055', normal, compile, [''])
{-# OPTIONS -fglasgow-exts #-}
-- 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.Generics
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
--gunfoldl k z c = case constrIndex c of
-- 1 -> k z (Leaf undefined undefined)
toConstr (Leaf _ _) = leafConstr
toConstr (Branch _ _ _ _) = branchConstr
dataTypeOf _ = itemDataType
itemDataType = mkDataType "Subliminal.Item" [leafConstr, branchConstr]
leafConstr = mkConstr itemDataType "Leaf" [] Prefix
branchConstr = mkConstr itemDataType "Branch" [] Prefix
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment