我是 Haskell 菜鸟,目前只用它来配置 xmonad。
我想把我的配置放到一个 git repo 中,因为我不想硬编码我的主目录来获取我的图标。
我查看了 http://www.haskell.org/haskellwiki/How_to_get_rid_of_IO 但我太无知了,无法理解。
hd h = h =<< getHomeDirectory
getIcon::String -> String
getIcon out = ( "^i("++hd++".xmonad/dzen2/"++out )
这真的可能吗?如果是这样,怎么做?我不想对目录进行操作,我只想要路径,作为一个字符串,它正在杀死我。
错误是:
Couldn't match expected type `[Char]' with actual type `(FilePath -> IO b0) -> IO b0' In the first argument of `(++)', namely `hd' In the second argument of `(++)', namely `hd ++ ".xmonad/dzen2/" ++ out' In the expression: ("^i(" ++ hd ++ ".xmonad/dzen2/" ++ out)
在我看来, IO monad 根本没有被删除。
更新:好的。我将学习如何适应 IO 规则,在此之前我将保持硬编码并使用将替换适当位的脚本克隆配置文件。