Overlapping and incoherent instances

Simon Peyton Jones simonpj at microsoft.com
Tue Jul 29 11:02:35 UTC 2014


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?


More information about the Glasgow-haskell-users mailing list