15 Aug 17:04
Overlapping instances vs. Haskell98 Report [was: How to disable warning for "export item 'module ...' exports nothing"?]
From: Sean Leather <leather <at> cs.uu.nl>
Subject: Overlapping instances vs. Haskell98 Report [was: How to disable warning for "export item 'module ...' exports nothing"?]
Newsgroups: gmane.comp.lang.haskell.glasgow.user
Date: 2008-08-15 15:06:19 GMT
Subject: Overlapping instances vs. Haskell98 Report [was: How to disable warning for "export item 'module ...' exports nothing"?]
Newsgroups: gmane.comp.lang.haskell.glasgow.user
Date: 2008-08-15 15:06:19 GMT
Ross Paterson wrote:
That's interesting. So, maybe there should be some language extension or warning (with associated -fno-warn) for this in GHC.
Personally, I prefer the way it's done now. (I guess that's obvious, considering I'm developing a library that will take advantage of it. ;) ) But it makes sense that instances are only looked up when needed, instead of globally tracked.
Sean
On Fri, Aug 15, 2008 at 04:17:44PM +0200, Sean Leather wrote:Then that is a GHC bug. Haskell 98 Report 4.3.2: "A type may not be
> module A where
> class A t where
> a :: t
>
> module B where
> import A
> instance A Int where
> a = 0
> a0 :: Int
> a0 = a
>
> module C where
> import A
> instance A Int where
> a = 1
> a1 :: Int
> a1 = a
>
> module Main where
> import A
> import B
> import C
> main = do putStrLn $ "a0=" ++ show a0
> putStrLn $ "a1=" ++ show a1
>
> This works, because of the way the instances are used. While overlapping
> instances are imported into Main, they are not used in Main.
declared as an instance of a particular class more than once in the
program."
That's interesting. So, maybe there should be some language extension or warning (with associated -fno-warn) for this in GHC.
Personally, I prefer the way it's done now. (I guess that's obvious, considering I'm developing a library that will take advantage of it. ;) ) But it makes sense that instances are only looked up when needed, instead of globally tracked.
Sean
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users <at> haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RSS Feed