Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: Architecture and monads (Amy de Buitl?ir) 2. A newbie question (Mianlai Zhou) 3. Re: A newbie question (Brandon S Allbery KF8NH) 4. Re: A newbie question (Mianlai Zhou) ---------------------------------------------------------------------- Message: 1 Date: Wed, 8 Dec 2010 14:27:05 +0000 From: Amy de Buitl?ir <a...@nualeargais.ie> Subject: Re: [Haskell-beginners] Architecture and monads To: Heinrich Apfelmus <apfel...@quantentunnel.de> Cc: beginners@haskell.org Message-ID: <aanlktindonkqy6jjt5nkjz52chvjogtzqxvpr4dnn...@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 > My advice is this: instead of using a state monad, use a monad that has > an independent interpretation. (You may *implement* it in terms of the > state monad, but you may not *think* of it as a state monad). Thank you so much. The advice and links you gave me are very helpful. ------------------------------ Message: 2 Date: Thu, 9 Dec 2010 00:18:45 +0800 From: Mianlai Zhou <mian...@gmail.com> Subject: [Haskell-beginners] A newbie question To: beginners@haskell.org Message-ID: <aanlktinmnf06+dytuof=+vseboh5vbv6rexgvd+mk...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" 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-0001.htm> ------------------------------ Message: 3 Date: Wed, 08 Dec 2010 11:48:57 -0500 From: Brandon S Allbery KF8NH <allb...@ece.cmu.edu> Subject: Re: [Haskell-beginners] A newbie question To: beginners@haskell.org Message-ID: <4cffb6f9.9090...@ece.cmu.edu> Content-Type: text/plain; charset=UTF-8 -----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] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@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----- ------------------------------ Message: 4 Date: Thu, 9 Dec 2010 01:18:26 +0800 From: Mianlai Zhou <mian...@gmail.com> Subject: Re: [Haskell-beginners] A newbie question To: beginners@haskell.org Message-ID: <aanlktine5gpn4bcgag4rljofvksr8vxb86dx_zboj...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Brandon, Thanks a lot for your explanation! M. Zhou On Thu, Dec 9, 2010 at 12:48 AM, Brandon S Allbery KF8NH < allb...@ece.cmu.edu> wrote: > -----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] allb...@kf8nh.com > system administrator [openafs,heimdal,too many hats] allb...@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----- > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20101209/8f89488d/attachment-0001.htm> ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 30, Issue 11 *****************************************