Haskell Ambiguous type variable in xmonad configuration

906 views Asked by At

I have an old xmonad config done by me copying blocks from other configs. I haven't much knowledge in Haskell so I have done my best till the moment. The thing is older compiler didn't complain about the this line in question but now shows an Ambigous type variable error.

I've checked other thread about similar problems but still cant figure how to solve my issue so if anyone could enlight me with any kind of answer I would be enormously thankfull.

The first Ambiguous type variable is shown after this expression:

xmonad $ defaultConfig
  { terminal            = myTerminal
  , workspaces          = myWorkspaces
  , keys                = myKeys
  , modMask             = mymodMask
  , layoutHook          = myLayoutHook
  , manageHook          = manageSpawn <+> myManageHook
  , logHook             = myLogHook dzenLeftBar
  , normalBorderColor   = colorNormalBorder
  , focusedBorderColor  = colorFocusedBorder
  , borderWidth         = 0
  , startupHook  = myStartupHook }

And the error is:

xmonad.hs:86:5: error:
        * Ambiguous type variable `l10` arising from a use of `xmonad`
          prevents the constraint `(LayoutClass
                                      l10 GHC.Word.Word64)` from being solved.
          Probable fix: use a type annotation to specify what `l10` should be.

The second error is thrown by the following expression:

onWorkspaces ["7:media"] mediaLayout $

And the error code is basically the same.

The full config file is this: https://paste.pound-python.org/show/BXD7gxeTXq14c5hQHwyK/

And the errors showed in the compiler are the following:

xmonad.hs:86:5: error:
    * Ambiguous type variable `l10` arising from a use of `xmonad`
      prevents the constraint `(LayoutClass
                                  l10 GHC.Word.Word64)` from being solved.
      Probable fix: use a type annotation to specify what `l10` should be.
      These potential instances exist:
        instance (LayoutClass l a, LayoutClass r a) =>
                 LayoutClass (Choose l r) a
          -- Defined in `XMonad.Layout`
        instance LayoutClass Full a -- Defined in `XMonad.Layout`
        instance LayoutClass l a => LayoutClass (Mirror l) a
          -- Defined in `XMonad.Layout`
        ...plus four others

        ...plus five instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    * In a stmt of a 'do' block:
        xmonad
        $ defaultConfig
            {terminal = myTerminal, workspaces = myWorkspaces, keys = myKeys,
             modMask = mymodMask, layoutHook = myLayoutHook,
             manageHook = manageSpawn <+> myManageHook,
             logHook = myLogHook dzenLeftBar,
             normalBorderColor = colorNormalBorder,
             focusedBorderColor = colorFocusedBorder, borderWidth = 0,
             startupHook = myStartupHook}
      In the expression:
        do { dzenLeftBar <- spawnPipe myXmonadBar;
             dzenStatusBar <- spawnPipe myStatusBar;
             dzenTrayBar <- spawnPipe myTrayBar;
             dzenMpdBar <- spawnPipe myMpdBar;
             .... }
      In an equation for `main`:
          main
            = do { dzenLeftBar <- spawnPipe myXmonadBar;
                   dzenStatusBar <- spawnPipe myStatusBar;
                   dzenTrayBar <- spawnPipe myTrayBar;
                   .... }

xmonad.hs:180:17: error:
    * Ambiguous type variable `l10` arising from a use of `onWorkspaces`
      prevents the constraint `(LayoutClass
                                  l10 Window)` from being solved.
      Relevant bindings include
        myLayoutHook :: XMonad.Layout.PerWorkspace.PerWorkspace
                          (ModifiedLayout
                             AvoidStruts
                             (Choose
                                (ModifiedLayout Spacing ResizableTall)
                                (Choose
                                   (Mirror (ModifiedLayout Spacing ResizableTall))
                                   (Choose
                                      (ModifiedLayout XMonad.Layout.NoBorders.WithBorder Full)
                                      (ModifiedLayout
                                         (XMonad.Layout.Decoration.Decoration
                                            SimpleDecoration
                                            XMonad.Layout.Decoration.DefaultShrinker)
                                         (ModifiedLayout
                                            XMonad.Actions.MouseResize.MouseResize
                                            (ModifiedLayout
                                               XMonad.Layout.WindowArranger.WindowArranger
                                               SimpleFloat)))))))
                          (XMonad.Layout.PerWorkspace.PerWorkspace
                             (ModifiedLayout
                                AvoidStruts
                                (Choose
                                   (ModifiedLayout
                                      XMonad.Layout.NoBorders.WithBorder
                                      (ModifiedLayout Spacing ResizableTall))
                                   (Choose
                                      (Mirror (ModifiedLayout Spacing ResizableTall))
                                      (Choose
                                         (ModifiedLayout XMonad.Layout.NoBorders.WithBorder Full)
                                         (ModifiedLayout
                                            (XMonad.Layout.Decoration.Decoration
                                               SimpleDecoration
                                               XMonad.Layout.Decoration.DefaultShrinker)
                                            (ModifiedLayout
                                               XMonad.Actions.MouseResize.MouseResize
                                               (ModifiedLayout
                                                  XMonad.Layout.WindowArranger.WindowArranger
                                                  SimpleFloat)))))))
                             (XMonad.Layout.PerWorkspace.PerWorkspace
                                (ModifiedLayout
                                   AvoidStruts
                                   (Choose
                                      (ModifiedLayout XMonad.Layout.NoBorders.WithBorder Full)
                                      (Choose
                                         (ModifiedLayout Spacing ResizableTall)
                                         (Choose
                                            (Mirror (ModifiedLayout Spacing ResizableTall))
                                            (ModifiedLayout
                                               (XMonad.Layout.Decoration.Decoration
                                                  SimpleDecoration
                                                  XMonad.Layout.Decoration.DefaultShrinker)
                                               (ModifiedLayout
                                                  XMonad.Actions.MouseResize.MouseResize
                                                  (ModifiedLayout
                                                     XMonad.Layout.WindowArranger.WindowArranger
                                                     SimpleFloat)))))))
                                (XMonad.Layout.PerWorkspace.PerWorkspace
                                   (ModifiedLayout
                                      AvoidStruts
                                      (Choose
                                         (ModifiedLayout
                                            XMonad.Layout.NoBorders.WithBorder
                                            (ModifiedLayout Spacing ResizableTall))
                                         (Choose
                                            (Mirror (ModifiedLayout Spacing ResizableTall))
                                            (Choose
                                               (ModifiedLayout
                                                  XMonad.Layout.NoBorders.WithBorder Full)
                                               (ModifiedLayout
                                                  (XMonad.Layout.Decoration.Decoration
                                                     SimpleDecoration
                                                     XMonad.Layout.Decoration.DefaultShrinker)
                                                  (ModifiedLayout
                                                     XMonad.Actions.MouseResize.MouseResize
                                                     (ModifiedLayout
                                                        XMonad.Layout.WindowArranger.WindowArranger
                                                        SimpleFloat)))))))
                                   (XMonad.Layout.PerWorkspace.PerWorkspace
                                      (ModifiedLayout
                                         AvoidStruts
                                         (ModifiedLayout
                                            XMonad.Layout.NoBorders.WithBorder
                                            (ModifiedLayout
                                               (XMonad.Layout.Decoration.Decoration
                                                  SimpleDecoration
                                                  XMonad.Layout.Decoration.DefaultShrinker)
                                               (ModifiedLayout
                                                  XMonad.Actions.MouseResize.MouseResize
                                                  (ModifiedLayout
                                                     XMonad.Layout.WindowArranger.WindowArranger
                                                     SimpleFloat)))))
                                      (XMonad.Layout.PerWorkspace.PerWorkspace
                                         l10
                                         (XMonad.Layout.PerWorkspace.PerWorkspace
                                            (ModifiedLayout
                                               AvoidStruts
                                               (ModifiedLayout
                                                  AddRoster
                                                  (ModifiedLayout
                                                     (XMonad.Layout.Decoration.Decoration
                                                        SimpleDecoration
                                                        XMonad.Layout.Decoration.DefaultShrinker)
                                                     (ModifiedLayout
                                                        XMonad.Actions.MouseResize.MouseResize
                                                        (ModifiedLayout
                                                           XMonad.Layout.WindowArranger.WindowArranger
                                                           SimpleFloat)))))
                                            (ModifiedLayout
                                               AvoidStruts
                                               (Choose
                                                  (ModifiedLayout
                                                     XMonad.Layout.NoBorders.WithBorder Full)
                                                  (Choose
                                                     (ModifiedLayout Spacing ResizableTall)
                                                     (Choose
                                                        (Mirror
                                                           (ModifiedLayout Spacing ResizableTall))
                                                        (ModifiedLayout
                                                           (XMonad.Layout.Decoration.Decoration
                                                              SimpleDecoration
                                                              XMonad.Layout.Decoration.DefaultShrinker)
                                                           (ModifiedLayout
                                                              XMonad.Actions.MouseResize.MouseResize
                                                              (ModifiedLayout
                                                                 XMonad.Layout.WindowArranger.WindowArranger
                                                                 SimpleFloat)))))))))))))
                          Window
          (bound at xmonad.hs:174:1)
      Probable fix: use a type annotation to specify what `l10` should be.
      These potential instances exist:
        instance (LayoutClass l a, LayoutClass r a) =>
                 LayoutClass (Choose l r) a
          -- Defined in `XMonad.Layout`
        instance LayoutClass Full a -- Defined in `XMonad.Layout`
        instance LayoutClass l a => LayoutClass (Mirror l) a
          -- Defined in `XMonad.Layout`
        ...plus four others
        ...plus five instances involving out-of-scope types
        (use -fprint-potential-instances to see them all)
    * In the expression: onWorkspaces ["7:media"] mediaLayout
      In the second argument of `($)`, namely
        `onWorkspaces ["7:media"] mediaLayout
         $ onWorkspaces ["8:com"] chatLayout $ simpLayout`
      In the second argument of `($)`, namely
        `onWorkspaces ["5:virt"] vBoxLayout
         $ onWorkspaces ["7:media"] mediaLayout
           $ onWorkspaces ["8:com"] chatLayout $ simpLayout`

xmonad.hs:202:15: error:
    * Couldn't match expected type `ModifiedLayout
                                      AddRoster
                                      (ModifiedLayout
                                         XMonad.Layout.Reflect.Reflect
                                         (ModifiedLayout
                                            AddRoster
                                            (ModifiedLayout
                                               TrackFloating
                                               (ModifiedLayout
                                                  (XMonad.Layout.Decoration.Decoration
                                                     TabbedDecoration
                                                     XMonad.Layout.Decoration.DefaultShrinker)
                                                  XMonad.Layout.Simplest.Simplest))))
                                      Window
                                    -> t`
                  with actual type `ModifiedLayout
                                      XMonad.Layout.NoBorders.WithBorder Full Window`
    * The first argument of ($) takes one argument,
      but its type `ModifiedLayout
                      XMonad.Layout.NoBorders.WithBorder Full Window`
      has none
      In the expression:
        noBorders Full
        $ withIM 0.11 (Role "gimp-toolbox")
          $ reflectHoriz
            $ withIM 0.15 (Role "gimp-dock") (trackFloating simpleTabbed)
      In an equation for `mediaLayout`:
          mediaLayout
            = noBorders Full
              $ withIM 0.11 (Role "gimp-toolbox")
                $ reflectHoriz
                  $ withIM 0.15 (Role "gimp-dock") (trackFloating simpleTabbed)
    * Relevant bindings include
        mediaLayout :: t (bound at xmonad.hs:202:1)

Please check the file for errors.
1

There are 1 answers

0
danr On

The problem is the mediaLayout definition, you're applying noBorders Full to something but it is a layout! Did you want it to be something like this below?

mediaLayout = noBorders Full |||
       ( withIM 0.11 (Role "gimp-toolbox") $ reflectHoriz
       $ withIM 0.15 (Role "gimp-dock") (trackFloating simpleTabbed)
       )