overlapping instances in 7.10.1
Sergei Meshveliani
mechvel at botik.ru
Mon Jun 15 12:25:44 UTC 2015
On Mon, 2015-06-15 at 09:29 +0000, Simon Peyton Jones wrote:
> | This is why I think that ghc-7.8.3 treats the OI notion in a more
> | natural way than ghc-7.10.1 does.
> | May be, ghc-7.10.1 has a better technical tool for this, but ghc-
> | 7.8.3 corresponds to a natural notion of OI.
> |
> | Can GHC return to a natural OI notion?
> | Or am I missing something?
>
> Well it all depends what you mean by "natural". To me it is profoundly un-natural to deliberately have the same type-class constraint solved in two different ways in the same program!
>
> To require this would prevent cross-module specialisation. If I have
> f :: C a => a -> a
> in one module, and I specialise it to
> f_spec :: [Int] -> [Int]
> in one module, I want to be free to re-use that specialisation in other modules. But under your "natural" story, I cannot do that, because (C [Int]) might be resolved differently there.
>
> I'd be interested in what others think. I've started
> https://ghc.haskell.org/trac/ghc/ticket/10526
> to collect these points.
>
> Meanwhile, Sergei, it's clear how to fix docon, so you are no longer stuck.
I hope DoCon is not stuck -- because it relies (so far) on ghc-7.8.3.
But I need to understand the subject of overlapping instances (OI).
----------
I am writing this _here_ because to clicking at
https://ghc.haskell.org/trac/ghc/ticket/10526
my browser responds Problem occurred while loading the URL
https://ghc.haskell.org/trac/ghc/ticket/10526
SSL handshake failed: A TLS fatal alert has been received.
Then, I start searching from https://ghc.haskell.org/trac/ghc/
and cannot find #10526
Also I had earlier a certain difficulty with registering to this bug
tracker, and suspect that registration was not fully successful, so that
I doubt that I can write there.
May I, please, discuss the subject here?
-------------------
The report of 7.10.1-errReport-may23-2015.zip
shows that 7.8.3 and 7.10.1 treat OI differently,
But this report is rather complex.
Instead consider the following simple example.
--------------------------------------------
module A where
class Size a where size :: a -> Int
instance {-# OVERLAPPING #-}
Size [a] where size = length
f :: Size a => a -> Int
f = size
g :: [Maybe Int] -> Int
g = size
----------------------------------------
module Main where
import A
instance {-# OVERLAPPING #-}
Size [Maybe a] where size _ = -1
mbs = [] :: [Maybe Int]
main = putStr (shows (f mbs) "\n") -- I -1
-- putStr (shows (g mbs) "\n") -- II 0
--------------------------------------------
Making and running in ghc-7.10.1 :
ghc --make -XFlexibleInstances Main
./Main
It prints "-1" for the line (I) for main,
and "0" for the line (II).
To compare to ghc-7.8.3, comment out the pragma and add
-XOverlappingInstances to the ghc call.
And this yields the same results -1 and -0 respectively.
Please, how to change (a bit) the above simple example in order to see
the difference between 7.8.3 and 7.10.1
?
Thanks,
------
Sergei
More information about the Glasgow-haskell-users
mailing list