Inconsistencies in `instance Monoid ManageHook'

Hi, The behavior of instance Monoid ManageHook is unnecessarily complicated. Perhaps the following example can convince you If a and b are defined with some arbitrary a', b' manipulations of the WindowSet like
a :: ManageHook a = do liftIO (putStrLn "a") doF a'
Then
a <+> b
can be written as
do liftIO (putStrLn "a") liftIO (putStrLn "b") doF (a' . b')
Side effects take place from left-to-right. The WindowSet is threaded from right-to-left through the functions (which could be produced as a result of those side effects). Possible correction: 1. Change ManageHook
type ManageHook = Query (Dual (Endo WindowSet))
For: All Monoid instances involved with XMonad would be left-to-right (Data.Map.Map prefering values on the left for duplicate keys doesn't fitting any direction in my opinion) Against: Will break quite a few configurations 2. Change instance Monoid (Query a)
instance (Monoid a) => Monoid (Query a) where mappend = flip (liftM2 (flip mappend))
For: Less code is likely to be broken by flipping the order that IO is run, since much fewer ManageHooks seem to involve liftX or liftIO for changing things that could be read later Against: Left-to-right remains a special case for ManageHook How much would you value consistency when using (<+>) = mappend with nearly all fields in XConfig? Are any current or reasonable uses of ManageHook be impossible if one of the composition orders were changed for consistency? -- Adam

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 8/3/10 00:57 , Adam Vogt wrote:
Are any current or reasonable uses of ManageHook be impossible if one of the composition orders were changed for consistency?
I have several ManageHooks which move e.g. IM windows to a particular desktop, and non-IM windows opened on that desktop to the next desktop in line. Do this backwards and it becomes an expensive no-op. :) - -- brandon s. allbery [linux,solaris,freebsd,perl] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.10 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkxXrIgACgkQIn7hlCsL25WBhQCcDun4U6sfJczMouwNQADQCdW3 OiUAn3jjIxfjwFP9qDHve25Vvd7VC+xN =r3aI -----END PGP SIGNATURE-----

* On Tuesday, August 03 2010, Brandon S Allbery KF8NH wrote:
On 8/3/10 00:57 , Adam Vogt wrote:
Are any current or reasonable uses of ManageHook be impossible if one of the composition orders were changed for consistency?
I have several ManageHooks which move e.g. IM windows to a particular desktop, and non-IM windows opened on that desktop to the next desktop in line. Do this backwards and it becomes an expensive no-op. :)
It isn't clear how your ManageHook depends on the IO and MonadState part being composed in the opposite order than Endo WindowSet. It would help to see the code. -- Adam
participants (2)
-
Adam Vogt
-
Brandon S Allbery KF8NH