[Haskell-beginners] A newbie question
Brandon S Allbery KF8NH
allbery at ece.cmu.edu
Wed Dec 8 17:48:57 CET 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 12/8/10 11:18 , Mianlai Zhou wrote:
> 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"?
It's just Haskell's syntax convention. Most Haskell declarations have the
format "<whatever> <name> where ..." (module, class, instance; data if GADTs
are enabled; functions also can have "where" clauses introducing local
definitions).
> 2. Why this module can end without an "end" sentence? And what are the blank
> lines treated as?
Haskell doesn't use keywords for delimiters; it mostly uses layout (like
Python but IMO a bit saner) although you can use explicit braces and
semicolons if you really want to. The module declaration is somewhat
special in that you don't have to indent the declarations in its "where"
clause; but the price of this is you can only have one module per file.
(Otherwise you'd have to either use braces or obey the layout rule and
indent everything.)
The blank lines do nothing special.
- --
brandon s. allbery [linux,solaris,freebsd,perl] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university KF8NH
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkz/tvkACgkQIn7hlCsL25VO2wCg1/MFpxwIAjhDlmvCVxqAmjMm
VJwAmgOrmX06F6EbQNKE9kORr+SlrLL/
=ktj3
-----END PGP SIGNATURE-----
More information about the Beginners
mailing list