Overlapping and incoherent instances
Simon Peyton Jones
simonpj at microsoft.com
Tue Jul 29 16:37:13 UTC 2014
| One other issue this brings up: how does this all interact with -XSafe?
| Right now, Safety can be inferred by looking at the set of LANGUAGE
| pragmas and the import list. (Right?) With the change as implemented,
| Safe inference would require looking at all instance declarations. Is
| this OK?
I'm honestly not sure, but I do know that, in the implementation, each instance declaration keeps track of (a) whether it is OVERLAPPABLE/OVERLAPPING/INCOHERENT, and (b) the setting of -XSafe in the module where the instance declaration is given.
This doesn't change. So I can't answer your question directly, but I think that the behaviour is unchanged from that at present.
Simon
|
| Richard
|
| On Jul 29, 2014, at 7:02 AM, Simon Peyton Jones <simonpj at microsoft.com>
| wrote:
|
| > The current implementation requires the pragma exactly where showed
| it.
| >
| > I'm not keen on allowing it to be separated.
| >
| > I suppose with some more parser jiggery pokery it could be allowed
| immediately before (or, better, after).
| >
| > But cpp would let you say
| >
| > instance
| > #if blah
| > {-# OVERLAPPABLE #-}
| > #endif
| > Show a => Show [a] where ...
| >
| > Simon
| >
| > | -----Original Message-----
| > | From: Johan Tibell [mailto:johan.tibell at gmail.com]
| > | Sent: 29 July 2014 11:02
| > | To: Herbert Valerio Riedel
| > | Cc: Niklas Hambüchen; Haskell Libraries (libraries at haskell.org);
| GHC
| > | users; Simon Peyton Jones; ghc-devs
| > | Subject: Re: Overlapping and incoherent instances
| > |
| > | On Tue, Jul 29, 2014 at 11:50 AM, Herbert Valerio Riedel
| > | <hvr at gnu.org>
| > | wrote:
| > | > On 2014-07-29 at 11:29:45 +0200, Niklas Hambüchen wrote:
| > | >>> instance {-# OVERLAPPABLE #-} Show a => Show [a] where .
| > | >>
| > | >> Is the syntax somewhat flexible in where the pragma can be
| placed?
| > | >> For example, some might prefer
| > | >>
| > | >> {-# OVERLAPPING #-}
| > | >> instance Show [Char] where .
| > | >
| > | > This variant may also be more convenient in cases where you need
| > | > to CPP-guard that pragma, as it's on a separate line.
| > |
| > | Agreed, and if we remove the old pragma (even with a deprecation
| > | cycle) you'll see quite a few of those as many library authors try
| > | to have their libraries compile with the last 3 major GHC versions.
| > |
| > | P.S. For e.g. INLINABLE we require that you mention the function
| > | name next to the pragma (which means that you can e.g. put the
| > | pragma after the declaration). What's the rationale to not require
| > |
| > | {-# OVERLAPPING Show [Char] #-}
| > |
| > | here? Perhaps it's too annoying to have to repeat the types?
| > _______________________________________________
| > Glasgow-haskell-users mailing list
| > Glasgow-haskell-users at haskell.org
| > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
| >
More information about the ghc-devs
mailing list