You are not logged in.
I am new to XMonad and trying to get into it. Following the Arch Linux wiki I configured xmonad + xmobar and everything works
Next I wanted to add custom keybindings using EZConfig's additionalKeysP function following the documentation at: http://xmonad.org/xmonad-docs/xmonad-co … onfig.html
xmonad.hs now looks like this:
import XMonad
import XMonad.Hooks.DynamicLog -- um Sachen in xmobar zu pipen
import XMonad.Util.EZConfig
main = xmonad =<< xmobar defaultConfig
{ terminal = "termite"
, borderWidth = 3
, focusedBorderColor = color0
}
`additionalKeysP`
[ ("M-p", spawn "termite") ]
color0 = "#fd971f"unfortunately I get this exception:
xmonad.hs:5:19: error:
• Couldn't match expected type ‘XConfig (XConfig l0)’
with actual type ‘IO
(XConfig
(XMonad.Layout.LayoutModifier.ModifiedLayout
XMonad.Hooks.ManageDocks.AvoidStruts
(Choose Tall (Choose (Mirror Tall) Full))))’
• In the first argument of ‘additionalKeysP’, namely
‘xmobar
(defaultConfig
{terminal = "termite", borderWidth = 3,
focusedBorderColor = color0})’
In the second argument of ‘(=<<)’, namely
‘xmobar
(defaultConfig
{terminal = "termite", borderWidth = 3,
focusedBorderColor = color0})
`additionalKeysP` [("M-p", spawn "rofi -show run")]’
In the expression:
xmonad
=<<
xmobar
(defaultConfig
{terminal = "termite", borderWidth = 3,
focusedBorderColor = color0})
`additionalKeysP` [("M-p", spawn "rofi -show run")]
xmonad.hs:5:19: error:
• Couldn't match type ‘XConfig’ with ‘IO’
Expected type: IO (XConfig l0)
Actual type: XConfig (XConfig l0)
• In the second argument of ‘(=<<)’, namely
‘xmobar
(defaultConfig
{terminal = "termite", borderWidth = 3,
focusedBorderColor = color0})
`additionalKeysP` [("M-p", spawn "rofi -show run")]’
In the expression:
xmonad
=<<
xmobar
(defaultConfig
{terminal = "termite", borderWidth = 3,
focusedBorderColor = color0})
`additionalKeysP` [("M-p", spawn "rofi -show run")]
In an equation for ‘main’:
main
= xmonad
=<<
xmobar
(defaultConfig
{terminal = "termite", borderWidth = 3,
focusedBorderColor = color0})
`additionalKeysP` [("M-p", spawn "rofi -show run")]I tried to put brackets around the config record, additionalKyesP and mapping list but this just lead to a syntax error.
I also put a `$` between xmobar and defaultConfig because it seems that the xombar processes the configuration before additionalKeysP is applied. But this also leads to an error.
I have no clue what is happening here.
Last edited by cutuchiqueno (2017-01-30 19:24:09)
Offline
You have a pretty large expression containing a variety of operators without any parentheses, so it all comes down to the operator precedence and associativity. You should at least know the following.
Function application (invisible/whitespace, like the space after "xmobar") binds strongest (highest precedence). It can be convenient to use the operator $ instead, to get function application with very low precedence, but that won't magically solve all your problems when mixing many operators in one expression.
If you want to apply a function to the result of an expression containing an operator, you need to put parentheses around this expression.
Constructing or updating a record (as in "defaultConfig {...}") is a bit of a special case and it binds even stronger than function application. It isn't really an operator and you don't need to use parentheses.
So, adding parentheses and removing some clutter, what you have on the right side of =<< is:
(xmobar (defaultConfig {..})) `additionalKeysP` []You need at least one pair of parentheses to make this work (point 2):
xmobar (defaultConfig {..} `additionalKeysP` [])Or you could give your custom config a name ("def" is a more general and newer replacement for defaultConfig):
main = xmonad =<< xmobar myConfig
myConfig = def {..} `additionalKeysP` []As a bonus, let's consider the use of the dollar sign ($) between xmobar and defaultConfig. The $ is function application with the lowest precedence, so even lower than =<<. That gives you:
(xmonad =<< xmobar) $ defaultConfig {..}which won't work because xmobar needs to be applied to a config first. On the left of =<< you have a function (xmonad) that needs an argument, but on the right you need a "complete" value. There is, however, a related operator that takes a function on both sides (like function composition for monadic functions). So, a third way to do this (probably need the import for this operator):
import Control.Monad
main = xmonad <=< xmobar $ def {..} `additionalKeysP` []Offline
thank you for this fantastic answer. On my way home in the bus the source of the problem occurred to me too. However when I was trying parentheses and function application I obviously did it wrong. Thus thanks relating all the different parts to each other in a way that showed me what I did wrong. The <=< I also hadn't seen before. I am really just on my way to learn Haskell (Haskellbook chp. 18 Nomads ;-)
Offline