Commit ddb23e1d authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Test Trac #4966

parent c872772f
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE OverlappingInstances #-}
module HTk.Toolkit.TreeList (getObjectFromTreeList) where
class Eq c => CItem c
-- A bizarre instance decl!
-- People who use instance decls like this are asking for trouble
instance GUIObject w => Eq w where
w1 == w2 = toGUIObject w1 == toGUIObject w2
data StateEntry a
= StateEntry (TreeListObject a) a -- Comment this 'a' out and it type checks
deriving Eq
-- The delicate point about this test is that we want to
-- infer a derived instance decl like this:
-- instance (CItem a, Eq a) => Eq (StateEntry a)
-- But note the instance decl for (Eq w) for any w!
-- There's a danger than we'll use that instance decl
-- to get the derived instance
-- instance (CItem a, GUIObject a) => Eq (StateEntry a)
-- And then that doesn't work subsequently
getObjectFromTreeList :: CItem a => StateEntry a -> Bool
getObjectFromTreeList state = state == state
data CItem a => TreeListObject a
instance CItem a => Eq (TreeListObject a)
class GUIObject w where
toGUIObject :: w -> GUIOBJECT
data GUIOBJECT
instance Eq GUIOBJECT where
(==) = undefined
(/=) = undefined
......@@ -25,6 +25,7 @@ test('T4220', normal, compile, [''])
test('T4302', normal, compile, [''])
test('T4325', normal, compile, [''])
test('T4816', normal, compile, [''])
test('T4966', normal, compile, [''])
test('drv-functor1', normal, compile, [''])
test('drv-functor2', normal, compile, [''])
......
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