Proposal: Left-Associative Semigroup Operator Alias in "Data.Semigroup"

Mario Blažević mblazevic at stilo.com
Mon Jun 6 13:45:25 UTC 2016


On 2016-06-06 07:30 AM, Herbert Valerio Riedel wrote:
> Hello!
>
> In short, the right-associative fixity of (Data.{Monoid,Semigroup}.<>)
> subtly conflicts with definitions of (<>) in pretty printing APIs, for
> which the left-associative variant is sometimes desirable. This subtle
> overloading of (<>) is error-prone, as one has to remember which version
> of (<>) is currently in scope in order to be able to reason about
> non-trivial expressions involving this operator.
>
> This proposal is an attempt to resolve this unfortunate and confusing
> situation by completing the `Semigroup`/`Monoid` vocabulary with a
> standard left-associative alias. Please see
>
>    https://ghc.haskell.org/trac/ghc/wiki/Proposal/LeftAssocSemigroupOp
>
> for more details.
>
> Discussion period: 4 weeks
>
>

	The proposal is well argued, but it omits any discussion of the proper 
place for the new operator. Why place it in Data.Semigroup, if its only 
purpose is to support the pretty-print libraries? Since the libraries in 
question will need to change anyway, or at least their imports will, why 
not add the operator there instead? Or, alternatively, to a 
Text.PrettyPrint module?



More information about the Libraries mailing list