darcs patch: XMonad.Config.Prime, a do-notation for config

Hello, folks, It's me again. First off, I see that you released 0.11 in Dec. Nice! Second, I took some time to take another crack at this config thing. (Previous thread: http://www.haskell.org/pipermail/xmonad/2012-September/013045.html.) Because of the problems you guys mentioned with Template Haskell, I: 1. replaced the fclabels dependency with the lighter data-accessor. 2. replaced the StateT with a fake monad, so the type of the layoutHook can be changed without that existential mess. The upside is an even cleaner syntax. The downside is: 1. You have to come to terms with having RebindableSyntax in your xmonad.hs. 2. Error messages are uglier (thanks, in part, to the really long layout types). Docs at: http://twifkak.com/xmonad-junk/XMonad-Config-Prime2.html Thoughts? Devin 1 patch for repository http://code.haskell.org/XMonadContrib: Mon Mar 11 02:46:17 PDT 2013 me@twifkak.com * XMonad.Config.Prime, a do-notation for config Note that the use of RebindableSyntax is because of the need to vary the layoutHook type throughout the config. The alternative, using the existential Layout type, was rejected because it required TemplateHaskell in order to look nice, and TemplateHaskell is not portable.

On Tue, Mar 12, 2013 at 5:30 AM,
Hello, folks,
It's me again. First off, I see that you released 0.11 in Dec. Nice! Second, I took some time to take another crack at this config thing. (Previous thread: http://www.haskell.org/pipermail/xmonad/2012-September/013045.html.)
Because of the problems you guys mentioned with Template Haskell, I: 1. replaced the fclabels dependency with the lighter data-accessor. 2. replaced the StateT with a fake monad, so the type of the layoutHook can be changed without that existential mess.
The upside is an even cleaner syntax. The downside is: 1. You have to come to terms with having RebindableSyntax in your xmonad.hs. 2. Error messages are uglier (thanks, in part, to the really long layout types).
Docs at: http://twifkak.com/xmonad-junk/XMonad-Config-Prime2.html
Thoughts? Devin
Hi Devin, Regarding the "TODO: Figure out how to type this without hard-coding the defaultConfig layout type.", maybe something is possible with -XRank2Types: xmonad :: (Read (l Window), LayoutClass l Window) => (forall l0. (Read (l0 Window), LayoutClass l0 Window) => XConfig l0 -> IO (XConfig l)) -> IO () But that only seems to work when prime includes a resetLayout, since the `l' isn't allowed to refer to the `l0'. It's still possible to write a type signature for XMonad.Config.Prime.xmonad, but since we aren't likely to change the type of defaultConfig anytime soon it's fine as-is. Some configs use do notation for IO in main before calling xmonad, or possibly for sequencing multiple X actions that are supposed to happen with a single keybinding. Enabling -XRebindableSyntax looks like it would force people to use a qualified name like Prelude.>>=, or put the definitions in separate modules. The second option is not necessarily a bad thing. Maybe it's possible to write a class with a >>= and >> that can work with IO or Prime, but that probably will make type errors even worse. -- Adam

On Wed, Mar 13, 2013 at 12:26:47AM -0400, adam vogt wrote:
since we aren't likely to change the type of defaultConfig anytime soon it's fine as-is.
Yeah, that's what I was thinking, too. I got rid of the TODO.
Some configs use do notation for IO in main before calling xmonad, or possibly for sequencing multiple X actions that are supposed to happen with a single keybinding. Enabling -XRebindableSyntax looks like it would force people to use a qualified name like Prelude.>>=, or put the definitions in separate modules. The second option is not necessarily a bad thing.
Maybe it's possible to write a class with a >>= and >> that can work with IO or Prime, but that probably will make type errors even worse.
Okay, I'll look into making such a class. If it doesn't make type errors even worse, it may challenge my type-fu, but I suppose that's a small price to pay. As a consolation, the definitions don't need to be in a separate module. This works: import qualified Prelude as P stuff :: IO () stuff = do spawn "xmessage hi" spawn "xmessage again" where (>>) = (P.>>) Also, FWIW, I got rid of the data-accessor dependency. On the way to making (=+) polymorph with the name of the attribute rather than its type (so I could support (=+) for the new EventMask fields and for 'keys' without running up against instance overlap), I had reimplemented the parts of it that this module uses. New patch attached, and new docs at: http://twifkak.com/xmonad-junk/XMonad-Config-Prime3.html Devin 7 patches for repository http://code.haskell.org/XMonadContrib: Mon Mar 11 02:46:17 PDT 2013 me@twifkak.com * XMonad.Config.Prime, a do-notation for config Note that the use of RebindableSyntax is because of the need to vary the layoutHook type throughout the config. The alternative, using the existen= tial Layout type, was rejected because it required TemplateHaskell in order to= look nice, and TemplateHaskell is not portable. Tue Mar 12 03:36:06 PDT 2013 me@twifkak.com * X.C.Prime: add support for the 3 newest fields Add support for clickJustFocuses, clientMask, and rootMask. Got rid of th= e ill-behaved Summable class. It may return pending a reworking of the acce= ssors. Wed Mar 13 00:38:18 PDT 2013 me@twifkak.com * X.C.Prime: reintroduce Summable class (and friends) This time it's a bit more structural, so it no longer misbehaves. Switche= d 'addKeys' to 'keys =3D+', etc. Wed Mar 13 00:41:13 PDT 2013 me@twifkak.com * X.C.Prime: add startWith (e.g. for gnomeConfig) Wed Mar 13 00:50:43 PDT 2013 me@twifkak.com * X.C.Prime: add 'applyIO' for some future flexibility Wed Mar 13 01:15:29 PDT 2013 me@twifkak.com * X.C.Prime: get rid of the data-accessor dependency The previous patch nearly obviated the library. This one does so complete= ly. Wed Mar 13 01:48:50 PDT 2013 me@twifkak.com * X.C.Prime: fix haddock errors -- Take the time to do it right, otherwise you will have to take the time to do it over. Lucky Numbers 14, 27, 34, 5, 38, 9 LEARN CHINESE - Gift Li-wu 礼物
participants (3)
-
adam vogt
-
Devin Mullins
-
me@twifkak.com