[Haskell] Creating a factorial function in GHC

2012-05-09 Thread Angus Comber
I am trying to create a factorial function in GHC.  I am following the
online learnyouahaskell.com book (specifically types-and-typeclasses
page).

Bear in mind this is my day 1 of learning Haskell.

The book suggests:

factorial :: Integer - Integer
factorial n = product [1..n]

But if I enter first line then press Enter I see:
interactive:1:1 Not in scope: 'factorial'

What am I doing wrong?

Angus

___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Creating a factorial function in GHC

2012-05-09 Thread Henning Thielemann


On Wed, 9 May 2012, Angus Comber wrote:


I am trying to create a factorial function in GHC.  I am following the
online learnyouahaskell.com book (specifically types-and-typeclasses
page).

Bear in mind this is my day 1 of learning Haskell.


Then beginn...@haskell.org might be a better place to ask, since
haskell@haskell.org is for announcements.



The book suggests:

factorial :: Integer - Integer
factorial n = product [1..n]

But if I enter first line then press Enter I see:
interactive:1:1 Not in scope: 'factorial'

What am I doing wrong?


The code you entered is intended to be the content of a text file that can 
be loaded into GHCi or Hugs. If you want to write it immediately into GHCi 
you may write:


Prelude let factorial :: Integer - Integer; factorial n = product [1..n]

___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell