Overlapping/Overlappable doesn't seem to do anything?
An example
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
class Foo a b where
foo :: a -> b
instance {-# OVERLAPPABLE #-} Show a => Foo a String where
foo = show
instance {-# OVERLAPPING #-} Read b => Foo String b where
foo = read
bar :: String -> String
bar = foo
files to compile with
• Overlapping instances for Foo String String
arising from a use of ‘foo’
Matching instances:
instance [overlappable] Show a => Foo a String
-- Defined at Incoh.hs:8:31
instance [overlapping] Read b => Foo String b
-- Defined at Incoh.hs:11:30
• In the expression: foo
In an equation for ‘bar’: bar = foo
|
15 | bar = foo
|
but other one is overlapping, and other one is overlappable, shouldn't the overlapping be picked?
When I read the documentation, the problem is that to dismiss other instance either one have to be strictly more specific than other, but the error message doesn't remind the user about that requirement.
The error is therefore confusing.