Your getIcon
has the wrong type, since getHomeDirectory
does IO:
getIcon :: String -> IO String
getIcon out = do
hd <- getHomeDirectory
return $ "^i(" ++ hd ++ ".xmonad/dzen2/" ++ out
Remember that Haskell distinguishes code that has side effects -- such as reading your hard disk -- via the type IO
.
So the caller would be in IO too:
main = do
s <- getIcon "foo"
.. now you have a regular string 's' ...