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 beginners@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]