patch: StackSet.hs edits

Hi all, I've begun going through the xmonad code carefully, in order to understand how it works, be able to contribute more, etc. Today I went through StackSet.hs. While I was going through I made a bunch of small changes (mostly documentation changes). The only code changes I made were (1) changing a gratuitous 'return' to 'Just'; (2) renaming 'findIndex' to 'findTag'. The second may be controversial; I don't know what the policy is on changing the names of functions exported by the core, but to me 'findTag' says *much* more clearly what the function does. I have also attached a patch for XMonadContrib which changes findIndex to findTag in the only contrib module which uses it, Dzen.hs. Obviously this patch should only be applied if the corresponding patch for core is made. -Brent

byorgey:
Hi all,
I've begun going through the xmonad code carefully, in order to understand how it works, be able to contribute more, etc. Today I went through StackSet.hs. While I was going through I made a bunch of small changes (mostly documentation changes). The only code changes I made were (1) changing a gratuitous 'return' to 'Just'; (2) renaming 'findIndex' to 'findTag'. The second may be controversial; I don't know what the policy is on changing the names of functions exported by the core, but to me 'findTag' says *much* more clearly what the function does.
The rule is you have to update the QuickCheck properties for that function, and any XMC modules that break in the process. As a result, we're fairly wary of changing names needlessly, and it also breaks some Config.hs files. So hard to say, as findTag is a better name.
I have also attached a patch for XMonadContrib which changes findIndex to findTag in the only contrib module which uses it, Dzen.hs. Obviously this patch should only be applied if the corresponding patch for core is made.
Good. How often is it used in Config.hs files, do you think? -- Don

On 10/22/07, Don Stewart
Hi all,
I've begun going through the xmonad code carefully, in order to understand how it works, be able to contribute more, etc. Today I went through StackSet.hs. While I was going through I made a bunch of small changes (mostly documentation changes). The only code changes I made were (1) changing a gratuitous 'return' to 'Just'; (2) renaming 'findIndex' to 'findTag'. The second may be controversial; I don't know what the
byorgey: policy
is on changing the names of functions exported by the core, but to me 'findTag' says *much* more clearly what the function does.
The rule is you have to update the QuickCheck properties for that function, and any XMC modules that break in the process. As a result, we're fairly wary of changing names needlessly, and it also breaks some Config.hs files. So hard to say, as findTag is a better name.
yup, understood. I did update the QuickCheck properties, and they all passed, and I'm currently running a version of xmonad compiled with findTag instead of findIndex. So I'm pretty confident I didn't break anything.
findTag in the only contrib module which uses it, Dzen.hs. Obviously
I have also attached a patch for XMonadContrib which changes findIndex to this
patch should only be applied if the corresponding patch for core is made.
Good. How often is it used in Config.hs files, do you think?
That's a good question. Not very often, I'd guess, but then again, I really have no idea. At the very least, I'm guessing it would only be used in Config.hs by people who know what they're doing and probably read this list. =) -Brent

byorgey:
Hi all,
I've begun going through the xmonad code carefully, in order to understand how it works, be able to contribute more, etc. Today I went through StackSet.hs. While I was going through I made a bunch of small changes (mostly documentation changes). The only code changes I made were (1) changing a gratuitous 'return' to 'Just'; (2) renaming 'findIndex' to 'findTag'. The second may be controversial; I don't know what the policy is on changing the names of functions exported by the core, but to me 'findTag' says *much* more clearly what the function does.
I have also attached a patch for XMonadContrib which changes findIndex to findTag in the only contrib module which uses it, Dzen.hs. Obviously this patch should only be applied if the corresponding patch for core is made.
Some comments are attached:
[StackSet.hs: (peek): why use return when you just mean Just? it
will just confuse the n00bs and return to haunt you later. Brent
Yorgey

[StackSet.hs: (peek): why use return when you just mean Just? it will just confuse the n00bs and return to haunt you later. Brent Yorgey
**20071022190732] { hunk ./StackSet.hs 314 -peek = with Nothing (return . focus) +peek = with Nothing (Just . focus) } I used return . focus here because it reads nicely :) After all, peek returns focus..
Ah. Well, you can keep it if you really want. =) It's just that I had to stare at it for a while to convince myself that I understood what it was doing. Especially in juxtaposition with the previous function (which has (Just . f)), it made me think, "wait, hmm, there must be a good reason that this one uses return but the one above uses Just..." It took me a while to realize that no, there really wasn't. -Brent

On Monday 22 October 2007 16:36:25 Brent Yorgey wrote:
Hi all,
I've begun going through the xmonad code carefully, in order to understand how it works, be able to contribute more, etc. Today I went through StackSet.hs. While I was going through I made a bunch of small changes (mostly documentation changes). The only code changes I made were (1) changing a gratuitous 'return' to 'Just'; (2) renaming 'findIndex' to 'findTag'. The second may be controversial; I don't know what the policy is on changing the names of functions exported by the core, but to me 'findTag' says *much* more clearly what the function does.
I have also attached a patch for XMonadContrib which changes findIndex to findTag in the only contrib module which uses it, Dzen.hs. Obviously this patch should only be applied if the corresponding patch for core is made.
-Brent
Don, do you think this should go in?

sjanssen:
On Monday 22 October 2007 16:36:25 Brent Yorgey wrote:
Hi all,
I've begun going through the xmonad code carefully, in order to understand how it works, be able to contribute more, etc. Today I went through StackSet.hs. While I was going through I made a bunch of small changes (mostly documentation changes). The only code changes I made were (1) changing a gratuitous 'return' to 'Just'; (2) renaming 'findIndex' to 'findTag'. The second may be controversial; I don't know what the policy is on changing the names of functions exported by the core, but to me 'findTag' says *much* more clearly what the function does.
I have also attached a patch for XMonadContrib which changes findIndex to findTag in the only contrib module which uses it, Dzen.hs. Obviously this patch should only be applied if the corresponding patch for core is made.
-Brent
Don, do you think this should go in?
Yes, and just note that if you use findIndex, your Config.hs will break. Otherwise, seems good.

byorgey:
Hi all,
I've begun going through the xmonad code carefully, in order to understand how it works, be able to contribute more, etc. Today I went through StackSet.hs. While I was going through I made a bunch of small changes (mostly documentation changes). The only code changes I made were (1) changing a gratuitous 'return' to 'Just'; (2) renaming 'findIndex' to 'findTag'. The second may be controversial; I don't know what the policy is on changing the names of functions exported by the core, but to me 'findTag' says *much* more clearly what the function does.
I have also attached a patch for XMonadContrib which changes findIndex to findTag in the only contrib module which uses it, Dzen.hs. Obviously this patch should only be applied if the corresponding patch for core is made.
-Brent
Applied. Note to findIndex users, findIndex is now findTag. -- Don
participants (3)
-
Brent Yorgey
-
Don Stewart
-
Spencer Janssen