Overlapping and incoherent instances

Richard Eisenberg eir at cis.upenn.edu
Tue Jul 29 12:13:22 UTC 2014


I think one nice thing about this proposal is that it doesn't seem (to me) to require CPP around the pragma: unrecognized pragmas are warned about but are otherwise harmless. Are folks very keen to have *warning-free* compilation on several GHC versions? Personally, I would aim for warning-free compilation on a most recent version, and otherwise successful compilation on older versions.

The only place CPP would be needed is around the LANGUAGE pragma, in order to avoid the deprecation warning in 7.10.

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?

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 Libraries mailing list