Haskell error parse error on input `='

后端 未结 4 1901
迷失自我
迷失自我 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:10

    A good rule of thumb for using ghci is that any code you enter should conform to do-block semantics; that is, you could assume syntactically that you're programming within the IO monad (if this is new terminology, don't worry! I'd highly recommend reading through this tutorial).

    This answer illustrates this point with an example, and may provide more working insight into the nature of IO and ghci.

提交回复
热议问题