[Haskell-beginners] defining functions in ghci

Tom Tobin korpios at korpios.com
Mon Jan 25 19:12:30 EST 2010

On Mon, Jan 25, 2010 at 5:38 PM, Joe Van Dyk <joe at fixieconsulting.com> wrote:
> This messes me up:
> $ ghci
> GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
> double x =Loading package base ... linking ... done.
> Prelude> double x = x + x
> <interactive>:1:9: parse error on input `='
> Why does that happen?

As others pointed out, you have to use "let" here; I don't know how
much you've experimented with monads yet (e.g., IO), but the reason is
that you're actually working in a monad in GHCi.

More information about the Beginners mailing list