summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_fail/tcfail096.hs
blob: 41dfd9099946096d775fd0ab72c4ce07a9ca314a (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 MultiParamTypeClasses, FunctionalDependencies,
             FlexibleInstances #-}
module ShouldFail where

class Foo f a r | f a -> r where
      foo::f->a->r

-- These instances are incompatible because we can unify
-- the first two parameters, though it's rather obscure:
--      p -> (a,b)
--      t -> (,) (a,a)
--      c -> (,) a
--      r -> s
--
-- So a constraint which would sow this up is
--      Foo ((Int,Int)->Int)
--          ((Int,Int), (Int,Int))
--          t
-- This matches both.  Not easy to spot, and the error
-- message would be improved by giving the unifier, or
-- a witness.

instance Foo (p->s)     (t p)    (t s)
instance Foo ((a,b)->r) (c a,c b)(c r)