小编use*_*484的帖子

在Haskell中连接String和IO Integer

我编写了一个函数,将当前屏幕宽度作为IO Integer返回(到目前为止工作).

getScreenWidth:: IO Integer
getScreenWidth = do
                    (sx, sy, w, h) <- getScreenDim 0
                    return $ sx
Run Code Online (Sandbox Code Playgroud)

现在我想将屏幕宽度添加到字符串:

> magic_function :: IO Integer -> String -> ... magic output type
> magic_function = ... ? this is where i am stack at ? ...
Run Code Online (Sandbox Code Playgroud)

我想魔术函数传递一个字符串,像"屏幕宽度:"我希望它添加当前屏幕的宽度,使我得到"屏幕宽度:1680".如何连接IO Integer和常用String?它有用show吗?

有人可以帮我吗?

string io haskell integer concatenation

3
推荐指数
1
解决办法
3126
查看次数

标签 统计

concatenation ×1

haskell ×1

integer ×1

io ×1

string ×1