blob: d6f12ada6ebc0cd5249a2e71ab8929a1dd2c6528 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
--Testing flexible and Overlapping instances
class C a where { f :: a -> String; f _ = "Default" }
instance C Int where { f _ = "Zeroth" }
:set -XFlexibleInstances
instance C [Int] where f _ = "First"
f [3::Int]
instance C a => C [a] where f xs = "Second"
f [4::Int] -- ***This should be an overlapping instances error!***
instance {-# OVERLAPPABLE #-} C a => C [a] where f xs = "Third"
f [5::Int] -- Should be fine
instance {-# OVERLAPPABLE #-} C a => C [a] where f xs = "Fourth"
f [6::Int] -- Should be fine too, overrides
instance C Bool where { f _ = "Bool" }
f [True] -- Should be fine too, overrides
|