You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lead may lead to an error because the resolved candidates would lead to indeterministic program behavior.
11
+
12
+
We can solve this by annotating the instances with the `{-# OVERLAPS #-}`, `{-# OVERLAPPING #-}`, `{-# OVERLAPPABLE #-}` and `{-# INCOHERENT #-}` pragma.
13
+
The former three can only be used if instances are *strictly more specific* than one another, i.e. the type of an instance can be substituted for the type of another instance.
14
+
15
+
Note that `{-# INCOHERENT #-}` still leads to indeterministic behavior and thus should be used with caution.
16
+
17
+
~~~
18
+
before/Overlapping.hs:18:19: error: [GHC-43085]
19
+
• Overlapping instances for Formatter (Maybe Int)
20
+
arising from a use of ‘format’
21
+
Matching instances:
22
+
instance Formatter (Maybe Int)
23
+
-- Defined at before/Overlapping.hs:13:10
24
+
instance Formatter a => Formatter (Maybe a)
25
+
-- Defined at before/Overlapping.hs:9:10
26
+
• In the second argument of ‘($)’, namely
27
+
‘format (Nothing :: Maybe Int)’
28
+
In the expression: putStrLn $ format (Nothing :: Maybe Int)
29
+
In an equation for ‘main’:
30
+
main = putStrLn $ format (Nothing :: Maybe Int)
31
+
|
32
+
18 | main = putStrLn $ format (Nothing :: Maybe Int)
0 commit comments