2014-08-27 136 views
1

愚蠢的簡單xmonad.hs問題...startupHook - 曖昧類型變量

import XMonad 

myTerminal = "gnome-terminal" 
startupHook = do { spawn "/usr/bin/feh --bg-fill /home/abennett/wallpaper.jpg" } 

main = xmonad defaults 

defaults = defaultConfig { 
     terminal = myTerminal 
} 

拋出這個錯誤:

 
Error detected while loading xmonad configuration file: /home/abennett/.xmonad/xmonad.hs 

xmonad.hs:4:20: 
    Ambiguous type variable `m0' in the constraint: 
     (MonadIO m0) arising from a use of `spawn' 
    Possible cause: the monomorphism restriction applied to the following: 
     Main.startupHook :: m0() (bound at xmonad.hs:4:1) 
    Probable fix: give these definition(s) an explicit type signature 
        or use -XNoMonomorphismRestriction 
    In a stmt of a 'do' block: 
     spawn "/usr/bin/feh --bg-fill /home/abennett/wallpaper.jpg" 
    In the expression: 
     do { spawn "/usr/bin/feh --bg-fill /home/abennett/wallpaper.jpg" } 
    In an equation for `Main.startupHook': 
     Main.startupHook 
      = do { spawn 
        "/usr/bin/feh --bg-fill /home/abennett/wallpaper.jpg" } 

Please check the file for errors 

我試過的東西像startupHook = startup然後startup = do { spawn "stuff" },但是那並不是」不管工作。

回答

2

您必須在您的defaults中包含startupHook。您可以直接在defaults中指定它,或者您創建一個變量並將其定義爲例如startupHookmyStartupHookdefaults(就像你與你的終端沒有):

import XMonad 

main = xmonad defaults 

defaults = defaultConfig { 
    terminal = myTerminal, 
    startupHook = myStartupHook 
    } 

myTerminal = "gnome-terminal" 

myStartupHook = do 
    spawn "/usr/bin/feh --bg-fill /home/abennett/wallpaper.jpg" 
    -- and more stuff like 
    spawn myTerminal 
    spawn "xclock" 

當你開始使用更多的工作空間,你可能會想用spawnOnXMonad.Actions.SpawnOn進口。

請看看xmonad config template,它會給你一個更好的想法如何建立你的配置文件。

+0

謝謝,這正是我需要的 – Systemspoet 2014-08-29 12:48:43