Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Io haskell如何将输入类型:String转换为Int_Io - Fatal编程技术网

Io haskell如何将输入类型:String转换为Int

Io haskell如何将输入类型:String转换为Int,io,Io,下面是将type:string转换为int的代码 get_int :: IO Int get_int = do num <-getLine return (read num :: Int) get_int::IO int get_int=do num我不确定,但我认为这与ghci不支持多行表达式有关 它在编译时工作 试一试 get_int=do num get_int = do num <-getLine;return (read num :: Int)

下面是将type:string转换为int的代码

get_int :: IO Int
get_int = do num <-getLine
             return (read num :: Int)
get_int::IO int

get_int=do num我不确定,但我认为这与ghci不支持多行表达式有关

它在编译时工作

试一试

get_int=do num
get_int = do num <-getLine;return (read num :: Int)