Haskell GHCI compiler: parsing error in repl when defining and declaring a simple function

I am reading the book, Teach You, Haskell.

I am trying to define this simple function, but the compiler spits it out. This is probably something very simple and simple, but I'm a complete newbie to Haskell:

GHCi, version 7.6.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> doubleMe x = x + x

<interactive>:2:12: parse error on input `='

Prelude>

+3
source share
2 answers

If you carefully read the book , it says (my attention):

Open your favorite text editor and click on this function, which takes a number and multiplies it by two.

    doubleMe x = x + x  

ghc, , ( ghci. , let " GHCI. let a = 1 GHCI a = 1 script, ." ). ghci , , let:

Prelude> let doubleMe x = x + x
Prelude> doubleMe 10
20
+5

GHCi let.

> let doubleMe x = x + x
> doubleMe 3
> 6
+1

All Articles