Haskell error parse error on input `='

后端 未结 4 1888
迷失自我
迷失自我 2020-12-07 19:54

I\'m new to Haskell and after starting ghci I tried:

f x = 2 * x

and I obtained:

:1:4: pars         


        
4条回答
  •  独厮守ぢ
    2020-12-07 20:28

    When you type into a Haskell source file,

    f x = 2 * x
    

    is correct.

    When you type directly into ghci, you need to type let at the start of the line:

    let f x = 2 * x
    

提交回复
热议问题