Coping with multiple meanings of `<>`

Sylvain Henry sylvain at
Wed Dec 15 08:53:42 UTC 2021

Hi Norman,

Usually in the compiler Semigoup's <> is imported qualified. But I agree 
it's ugly.

The trouble with Outputable's <> is that:
1) it doesn't have the same associativity as Semigroup's <>
2) <+> interacts weirdly with <> (cf

I have rediscovered this when trying to fix it 2 months ago:

I have tried to add a new constructor to fix (2) 
but it's still failing 

Any help fixing these issues would be appreciated :)


On 14/12/2021 20:23, Norman Ramsey wrote:
> I find myself wanting to define instances of Semigroup (and Monoid)
> in a file that also imports GHC.Utils.Outputable and its `<>` operation
> on SDocs.  At the moment I am dealing with the incompatibility by
> hiding the Outputable version and instead of writing `s1 <> s2` I write
> `hcat [s1, s2]`.  This workaround seems ugly and vaguely embarrassing.
> How are others dealing with this issue?  Would it be sensible simply
> to make SDoc an instance of Semigroup (and Monoid), or would we be
> concerned about potential additional overhead at compile time?
> Norman
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at

More information about the ghc-devs mailing list