Haskell Error: parse error on input `='

后端 未结 5 2120
执笔经年
执笔经年 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:40

    Saizan on #haskell explains that the assignments in a let expression have to align, not let itself. As long as the assignments line up, it's okay to use hard tabs or soft tabs.

    Correct code:

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

提交回复
热议问题