[xmonad] How to organize myLayoutHook?

Jeffrey David Johnson jefdaj at gmail.com
Wed Oct 17 18:13:25 CEST 2012


Hm I wasn't able to get it to work, though I'm not sure why. It looks 
like it should. Actual code:

myLayoutHook = avoidStruts
              $ smartBorders
              $ format
              [ ("admin", "~/dotfiles", base         )
              , ("notes", "~/notes"   , tall ||| wide)
              ]
     where
         format (w:[]) = workspace w base
         format (w:ws) = workspace w $ format ws
         workspace (n,d,l) = onWorkspace n l $ modWorkspace n 
(workspaceDir d)

         base = Full ||| tall ||| Grid ||| wide
         tall = named "tall" $ FixedColumn 1 20 80 10
         wide = named "wide" $ Mirror $ tall
         gimp = named "gimp" $ withIM (0.15) (Role "gimp-toolbox")
                             $ reflectHoriz
                             $ withIM (0.25) (Role "gimp-dock")
                             $ base

And the resulting error:

xmonad.hs:43:40:
     Couldn't match type `XMonad.Layout.LayoutModifier.ModifiedLayout
                            XMonad.Layout.Renamed.Rename FixedColumn'
                   with `Full'
     Expected type: Full a0
       Actual type: XMonad.Layout.LayoutModifier.ModifiedLayout
                      XMonad.Layout.Renamed.Rename FixedColumn a0
     In the first argument of `(|||)', namely `tall'
     In the expression: tall ||| wide
     In the expression: ("notes", "~/notes", tall ||| wide)

xmonad.hs:43:49:
     Couldn't match type `XMonad.Layout.LayoutModifier.ModifiedLayout
                            XMonad.Layout.Renamed.Rename
                            (Mirror
(XMonad.Layout.LayoutModifier.ModifiedLayout
                                  XMonad.Layout.Renamed.Rename 
FixedColumn))'
                   with `NewSelect
(XMonad.Layout.LayoutModifier.ModifiedLayout
                              XMonad.Layout.Renamed.Rename FixedColumn)
                           (NewSelect
                              Grid
(XMonad.Layout.LayoutModifier.ModifiedLayout
                                 XMonad.Layout.Renamed.Rename
                                 (Mirror
(XMonad.Layout.LayoutModifier.ModifiedLayout
                                       XMonad.Layout.Renamed.Rename 
FixedColumn))))'
     Expected type: NewSelect
                      (XMonad.Layout.LayoutModifier.ModifiedLayout
                         XMonad.Layout.Renamed.Rename FixedColumn)
                      (NewSelect
                         Grid
                         (XMonad.Layout.LayoutModifier.ModifiedLayout
                            XMonad.Layout.Renamed.Rename
                            (Mirror
(XMonad.Layout.LayoutModifier.ModifiedLayout
                                  XMonad.Layout.Renamed.Rename 
FixedColumn))))
                      a0
       Actual type: XMonad.Layout.LayoutModifier.ModifiedLayout
                      XMonad.Layout.Renamed.Rename
                      (Mirror
                         (XMonad.Layout.LayoutModifier.ModifiedLayout
                            XMonad.Layout.Renamed.Rename FixedColumn))
                      a0
     In the second argument of `(|||)', namely `wide'
     In the expression: tall ||| wide
     In the expression: ("notes", "~/notes", tall ||| wide)

xmonad.hs:46:25:
     Couldn't match expected type `NewSelect
                                     Full
                                     (NewSelect
(XMonad.Layout.LayoutModifier.ModifiedLayout
XMonad.Layout.Renamed.Rename FixedColumn)
                                        (NewSelect
                                           Grid
(XMonad.Layout.LayoutModifier.ModifiedLayout
XMonad.Layout.Renamed.Rename
                                              (Mirror
(XMonad.Layout.LayoutModifier.ModifiedLayout
XMonad.Layout.Renamed.Rename FixedColumn)))))
                                     a0
                                   -> t0'
                 with actual type `PerWorkspace
                                     l10
                                     ((->) (l0 a1))
                                     (PerWorkspace
(XMonad.Layout.LayoutModifier.ModifiedLayout WorkspaceDir l0)
                                        l0
                                        a1)'
     The function `workspace' is applied to two arguments,
     but its type `(WorkspaceId,
                    String,
                    l10 (PerWorkspace
(XMonad.Layout.LayoutModifier.ModifiedLayout WorkspaceDir l0)
                           l0
                           a1))
                   -> PerWorkspace
                        l10
                        ((->) (l0 a1))
                        (PerWorkspace
(XMonad.Layout.LayoutModifier.ModifiedLayout WorkspaceDir l0)
                           l0
                           a1)'
     has only one
     In the expression: workspace w base
     In an equation for `format': format (w : []) = workspace w base

xmonad.hs:47:25:
     Couldn't match expected type `t0 -> t0'
                 with actual type `PerWorkspace
                                     l10
                                     ((->) (l0 a1))
                                     (PerWorkspace
(XMonad.Layout.LayoutModifier.ModifiedLayout WorkspaceDir l0)
                                        l0
                                        a1)'
     The first argument of ($) takes one argument,
     but its type `PerWorkspace
                     l10
                     ((->) (l0 a1))
                     (PerWorkspace
                        (XMonad.Layout.LayoutModifier.ModifiedLayout 
WorkspaceDir l0)
                        l0
                        a1)'
     has none
     In the expression: workspace w $ format ws
     In an equation for `format':
         format (w : ws) = workspace w $ format ws


I did make some progress in a different direction, with separate lists 
for each modifier:

myLayoutHook = avoidStruts
              $ smartBorders
              $ dirs
              $ layouts

     where
         layouts = format ("4:gimp", gimp)
                 $ base

             where
                 format (a,b) = onWorkspace a b
                 base = Full ||| tall ||| Grid ||| wide

                 tall = named "tall" $ FixedColumn 1 20 80 10
                 wide = named "wide" $ Mirror $ tall
                 gimp = named "gimp" $ withIM (0.15) (Role "gimp-toolbox")
                                     $ reflectHoriz
                                     $ withIM (0.25) (Role "gimp-dock")
                                     $ base

         dirs = format ("1:admin" , "~/dotfiles")
              . format ("2:notes", "~/notes")
              . base
             where
                 format (a,b) = modWorkspace a (workspaceDir b)
                 base = workspaceDir "~"

The only thing is I wasn't able to make them into actual lists. If I 
change the last part to:

dirs = foldr (.) base $ map format
     [ ("1:admin", "~/dotfiles")
     , ("2:notes", "~/notes"   )
     ]
     where
         format (a,b) = modWorkspace a (workspaceDir b)
         base = workspaceDir "~"

This happens:

xmonad.hs:59:37:
     Couldn't match type `PerWorkspace
(XMonad.Layout.LayoutModifier.ModifiedLayout
                               WorkspaceDir
(XMonad.Layout.LayoutModifier.ModifiedLayout WorkspaceDir l0))
(XMonad.Layout.LayoutModifier.ModifiedLayout WorkspaceDir l0)
                            a0'
                   with `XMonad.Layout.LayoutModifier.ModifiedLayout
                           WorkspaceDir l0 a0'
     Expected type: (WorkspaceId, String)
                    -> XMonad.Layout.LayoutModifier.ModifiedLayout 
WorkspaceDir l0 a0
                    -> XMonad.Layout.LayoutModifier.ModifiedLayout 
WorkspaceDir l0 a0
       Actual type: (WorkspaceId, String)
                    -> XMonad.Layout.LayoutModifier.ModifiedLayout 
WorkspaceDir l0 a0
                    -> PerWorkspace
                         (XMonad.Layout.LayoutModifier.ModifiedLayout
                            WorkspaceDir
(XMonad.Layout.LayoutModifier.ModifiedLayout WorkspaceDir l0))
                         (XMonad.Layout.LayoutModifier.ModifiedLayout 
WorkspaceDir l0)
                         a0
     In the first argument of `map', namely `format'
     In the second argument of `($)', namely
       `map format [("1:admin", "~/dotfiles"), ("2:notes", "~/notes")]'
     In the expression:
       foldr (.) base
       $ map format [("1:admin", "~/dotfiles"), ("2:notes", "~/notes")]

But that's just nitpicking because they're managable as is now. :)
Jeff

On 10/17/12 00:48, Daniel Trstenjak wrote:
> On Wed, Oct 17, 2012 at 09:34:06AM +0200, Daniel Trstenjak wrote:
>>          format (w:[]) = workspace w
>>          format (w:ws) = workspace w ||| format ws
>>
>>          workspace (name, dir, layouts) = onWorkspace name layouts defaultWorkspace
>>                                              ||| modWorkspace name (workspaceDir dir) defaultWorkspace
> Wait, I think the usage of ||| is wrong here, because it would result in more layouts than
> you want. So it should be more something like (again, without testing):
>
>          format (w:[]) = workspace w defaultWorkspace
>          format (w:ws) = workspace w $ format ws
>
>          workspace (name, dir, layouts) = onWorkspace name layouts $ modWorkspace name (workspaceDir dir)
>
>
>
> Greetings,
> Daniel
>
> _______________________________________________
> xmonad mailing list
> xmonad at haskell.org
> http://www.haskell.org/mailman/listinfo/xmonad




More information about the xmonad mailing list