{-# LANGUAGE ScopedTypeVariables, MultiParamTypeClasses, FunctionalDependencies #-}

-- This loads fine, but Test1a.hs requires FlexibleInstances and then fails to
-- infer the necessary Bar instance

module Test1 where

class Foo a b | a -> b where
   foo :: b -> a
   foo' :: a -> Int

class Bar b where
   bar :: b -> Int

instance Foo a b => Bar (Either a b) where
   bar (Left a) = foo' a
   bar (Right b) = foo' (foo b :: a)

instance Foo Int Int where
   foo = id
   foo' = id

val :: Either Int Int
val = Left 5

res :: Int
res = bar val