Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/8.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
如何在haskell中将用户定义的数据用作参数?_Haskell - Fatal编程技术网

如何在haskell中将用户定义的数据用作参数?

如何在haskell中将用户定义的数据用作参数?,haskell,Haskell,我是哈斯克尔的新手 我有这个计划: loop height weight=do line<-getLine if line=="1" then do height<-getLine loop height weight else if line=="2" then do weight<-getLine loop height

我是哈斯克尔的新手

我有这个计划:

loop height weight=do
    line<-getLine
    if line=="1" then
        do
            height<-getLine
            loop height weight
    else if line=="2" then
        do 
            weight<-getLine
            loop height weight
        else if line=="3" then
            do
                putStrLn (height)
            else
                do
                    putStrLn "error"

main :: IO ()
main = do
    loop "" ""
loop height weight=do

行您可以使用记录更新表示法:

if line=="1" then
    do
        height'<-getLine
        loop z{height = height'}
如果行==“1”,则
做

高度'您可以使用记录更新表示法:

if line=="1" then
    do
        height'<-getLine
        loop z{height = height'}
如果行==“1”,则
做
高度'