[Haskell-beginners] A newbie question

Mianlai Zhou mianlai at gmail.com
Wed Dec 8 17:18:45 CET 2010


Hello All,

Today I wrote my first Haskell program, which is

module Main
   where

f 1 = 1
f n = n*f(n-1)
main = putStrLn (show (f 5))


After compilation, this program runs with no problem and gives 120 (which is
correct).
I have two questions though:

1. What does "where" in line 2 mean? Why I should put it here in this place?
If there is no "where"
here, the program cannot run. But what is the syntactical meaning of
"where"?

2. Why this module can end without an "end" sentence? And what are the blank
lines treated as?

Thank you for your answer, well, in advance. These are newbie questions
indeed.

Best wishes,

Mr. Zhou
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20101209/a39dd76f/attachment.htm>


More information about the Beginners mailing list