Haskell Error: parse error on input `='

后端 未结 5 2102
执笔经年
执笔经年 2021-01-05 10:14

Specs

GHC 6.12.1

Mac OS X 10.6.4 x64

MacBook Pro

Problem

I\'m having trouble using let

5条回答
  •  南方客
    南方客 (楼主)
    2021-01-05 10:30

    Indent each declaration in the let-block to the same degree. Also good form is to indent the 'in' and 'let' to the same level. Eg..

    main = let x = 1
               y = 2
               z = 3
           in putStrLn $ "X = " ++ show x ++ "\nY = " ++ show y ++ "\nZ = " ++ show z
    

提交回复
热议问题