0

Running Manjaro and trying to get XMonad to work I encountered a parse error on input '{' with the following xmonad.hs:

import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO

main = do
  xmproc <- spawnPipe "xmobar"

  xmonad $ defaultConfig
  { manageHook = manageDocks <+> manageHook defaultConfig
  , layoutHook = avoidStruts  $  layoutHook defaultConfig
  , logHook = dynamicLogWithPP xmobarPP
          { ppOutput = hPutStrLn xmproc
          , pptitle = xmobarColor "green" "" . shorten 50
          }
  , modMask = mod4Mask   -- rebind Mod to the windows key
  } `additionalKeys`
  [ ((mod4Mask .|. shiftMask, xK_z), spawn "xscreensaver-command -lock; xset dmps force off")
  , ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s")
  , ((0, xK_Print), spawn "scrot")
  ]

I have found this solution on su.sx and took my xmonad.hs from readthedocs.io. For getting started I would like to use that config file, I do not know however how to apply the solution to this. If somebody proficient could explain why that error appears and how to fix it, I'd really appreciate it since I just recently started with Haskell and it's really bending my mind to an unknown extent... :D

duplode
  • 33,731
  • 7
  • 79
  • 150
tifrel
  • 421
  • 8
  • 20
  • 1
    Well, what do you think how the compiler parses this code? (Draw parentheses) Hint: the solution on SuperUser that you've linked doesn't have the error. – leftaroundabout May 20 '17 at 21:28

1 Answers1

2

Indent everything after the xmonad $ defaultConfig line further to the right (it seems some of the indentation was lost when you pasted the example):

main = do
    xmproc <- spawnPipe "xmobar"

    xmonad $ defaultConfig
        { manageHook = manageDocks <+> manageHook defaultConfig
        , layoutHook = avoidStruts  $  layoutHook defaultConfig
        , logHook = dynamicLogWithPP xmobarPP
                        { ppOutput = hPutStrLn xmproc
                        , ppTitle = xmobarColor "green" "" . shorten 50
                        }
        , modMask = mod4Mask     -- Rebind Mod to the Windows key
        } `additionalKeys`
        [ ((mod4Mask .|. shiftMask, xK_z), spawn "xscreensaver-command -lock; xset dpms force off")
        , ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s")
        , ((0, xK_Print), spawn "scrot")
        ]

Lines at the "parent" indentation level in a do-block are parsed as separate statements, which is not appropriate here.

duplode
  • 33,731
  • 7
  • 79
  • 150