summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghci/scripts/ghci044.script
blob: d86557d317980eff0812a6d7236ae72bd7283808 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
:set -fno-warn-redundant-constraints
--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