[xmonad] Importing Stackset qualified

Gwern Branwen gwern0 at gmail.com
Tue Jun 8 16:43:01 EDT 2010


On Mon, May 17, 2010 at 5:49 PM, Adam Vogt <vogt.adam at gmail.com> wrote:
> * On Monday, May 17 2010, Gwern Branwen wrote:
>
>>I noticed yesterday in my config, 'import qualified XMonad.StackSet as
>>W', and I wondered - why do we do that? Is there some rationale behind
>>it or is it just tradition?
>>
>>I ask because if the former, then there are quite a few modules in XMC
>>which don't import it as W, or as anything at all; a quick grep:
>>
>> ...
>>
>>If the former, then several of these need to be fixed or changed, I think.
>>
>>--
>>gwern
>
> It's qualified because some names are reused: XMonad.StackSet.focus,
> XMonad.Operations.focus
>
> Consistent qualifications make it a bit easier to understand code, but
> you can usually tell between those: if you imported both modules as
> different random names, the types are sufficiently different that you
> can guess which is which (Window -> X ()) is used quite differently than
> (Stack a -> a).
>
> I'm not against widespread changes to import style in the name of
> consistency, but do take care to address unapplied patches beforehand,
> to avoid having to resolve conflicts.

XMonad.Operations is very rarely imported, it seems:

[04:32 PM] 0Mb$ gr XMonad.Operations|g import
Actions/MessageFeedback.hs:import XMonad.Operations ( updateLayout )
Actions/GroupNavigation.hs:import XMonad.Operations
Actions/WindowGo.hs:import XMonad.Operations (windows)
Util/Paste.hs:import XMonad.Operations (withFocused)

Now, specifying the used operations seems to be safe, so I made the
following changes to the module which doesn't enumerate its imports.

hunk ./XMonad/Actions/GroupNavigation.hs 32
-import Control.Monad
hunk ./XMonad/Actions/GroupNavigation.hs 35
-import Data.Maybe
hunk ./XMonad/Actions/GroupNavigation.hs 41
-import XMonad.Operations
+import XMonad.Operations (windows, withFocused)

I don't know how those unnecessary imports got past -Wall, but I'm
removing them while I'm at it.

Unfortunately Adam, this change would conflict with your 'Use cabal's
cpp macros to restore containers-0.2 compatiblity' patch. So perhaps
we should move on that patch?

(Once Operations imports are dealt with, I can look into fixing up the
StackSet imports. I'd like a uniform approach which we could put into
the hacking guidelines.)

-- 
gwern


More information about the xmonad mailing list