[xmonad] Re: Why isn't mappend for Query flipped?

Brent Yorgey byorgey at seas.upenn.edu
Tue Jun 9 21:45:02 EDT 2009


On Tue, Jun 09, 2009 at 07:42:58PM -0400, Chung-chieh Shan wrote:
> Brent Yorgey <byorgey at seas.upenn.edu> wrote in article <20090609164904.GA5859 at seas.upenn.edu> in gmane.comp.lang.haskell.xmonad:
> > The upshot is that
> >   m1 <+> m2
> > does m2, and THEN m1....
> > I propose to change the Monoid instance for Query so that 
> >     mappend = liftM2 (flip mappend)
> 
> When m2 is done followed by m1, sometimes the effect of m1 "takes
> precedence" (for example, when "doFloat" is pitted against "unfloat =
> ask >>= \w -> doF (W.sink w)") but sometimes the effect of m2 "takes
> precedence".  I have had to reason about what takes precedence, and this
> proposed change would make the reasoning harder for me, simply because
> "flip" is one more level of indirection and I am already used to the
> match between "mappend" and the mathematical convention for function
> composition.  So, I would say that the proposed change should be made
> iff this new meaning of <+> can be documented clearly and predictably
> without reference to the Endo Monoid notion of function composition.

Hmm.  I can see how that would be confusing.  I suppose another
solution would be to just add another combinator which is like <+> but
flipped, with some clear documentation.  Actually, just adding some
clearer documentation would probably go a long way without even
changing any code.

-Brent


More information about the xmonad mailing list