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 [EMAIL PROTECTED]
You can reach the person managing the list at [EMAIL PROTECTED] When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: Homework help (was Re: Help in Haskell) (Benjamin L.Russell) 2. Re: Re: Homework help (was Re: Help in Haskell) (Tillmann Rendel) 3. Re: [Haskell] Re: Help : A problem with IO (abdullah abdul Khadir) 4. ANNOUNCE: Haskell Communities and Activities Report (15th ed., November 2008) (Janis Voigtlaender) 5. Wrapping random (Torsten Otto) 6. Re: Wrapping random (Steven Ashley) ---------------------------------------------------------------------- Message: 1 Date: Thu, 27 Nov 2008 18:32:01 +0900 From: Benjamin L.Russell <[EMAIL PROTECTED]> Subject: [Haskell-beginners] Re: Homework help (was Re: Help in Haskell) To: beginners@haskell.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=us-ascii Nevertheless, there is such a thing as a consensus, and given the role of this mailing list, it does seem that rewriting the "Homework help - HaskellWiki" page in a more egalitarian manner may be worth a try. After all, any changes can be immediately reversed, and I can't see any harm in rewriting the page in a more beginner-friendly manner. Therefore, I have taken the liberty of revising the above-mentioned HaskellWiki page in a less elitist manner, which had long been my eventual intent. We'll see what happens. With luck, the new egalitarian tone will stay. -- Benjamin L. Russell On Thu, 27 Nov 2008 16:44:34 +0900, Benjamin L.Russell <[EMAIL PROTECTED]> wrote: >On Wed, 26 Nov 2008 18:18:45 -0500, [EMAIL PROTECTED] wrote: > >>G'day Benjamin. >> >>Quoting "Benjamin L.Russell" <[EMAIL PROTECTED]>: >> >>> As such, first, please follow the homework help procedure outlined in >>> "Homework help - HaskellWiki" (see >>> http://www.haskell.org/haskellwiki/Homework_help) (substitute >>> "haskell-beginners or haskell-cafe" for "haskell-cafe," and just >>> ignore the part about the existence of "stupid questions"--there is no >>> such thing as a "stupid question"; however, there are such things as >>> appropriate questions and inappropriate questions, and in order for us >>> to help you appropriately in this context, you need to show us more >>> specifically what you have done and where you are stuck, so that we >>> can provide help that would be appropriate in this context). >> >>It's a wiki. If the wording is bad, fix it! > >Actually, initially I had to fight the urge not to rewrite it in a >less elitist manner, in order to avoid the possibility of offending >the original author. > >In fact, I had been thinking about changing that page since about >December of 2007, when I think I first saw it, but had hesitated out >of a concern that doing so would have gone against the intent of the >original author of that page. On a related issue, I had previously >encountered a number of participants on Haskell-Cafe who had reacted >negatively against what they apparently thought were "stupid >questions": One of them even asked (in private e-mail) that a >participant not "pollute" Haskell-Cafe by asking about whether screen >resolution was important in determining the precision of an algorithm >to compute prime numbers by picking points randomly from a square. > >I refrained from changing the page because of the possibility that the >original author may have been an elitist, who could have changed it >back immediately. > >Part of my original purpose in suggesting the creation of >Haskell-Beginners was to create a more non-elitist, beginner-friendly >atmosphere. > >More specifically, since HaskellWiki is also visible to participants >on Haskell-Cafe, and not just to those on Haskell-Beginners, if I >changed the original intent of the sentence by rephrasing the >following sentence (see >http://www.haskell.org/haskellwiki/Homework_help): > >>Your lecturer/instructor may have told you that there is no such thing as a >>stupid question. Inside your classroom, that is correct. Outside your >>classroom, there are smart questions and stupid questions. If you ask a smart >>question of the Haskell community, you will probably get a helpful answer. If >>you ask a stupid question, you will probably get an unhelpful answer or, more >>likely, no answer at all. > >to the following sentence: > >>Your lecturer/instructor may have told you that there is no such thing as a >>stupid question. Indeed, that is correct. However, independent of the >>context, there are appropriate questions and inappropriate questions. If you >>first attempt to solve a problem with a decent amount of effort, then get >>stuck, and then ask for a hint from the Haskell community, your question will >>most likely be viewed as appropriate, and you will probably get a helpful >>answer. If you do not attempt to solve the problem, but try to get somebody >>else to solve the entire problem for you, your question will most likely be >>viewed as inappropriate, and you will probably get an unhelpful answer or, >>more likely, no answer at all. > >I could have risked going against the cultural attitude of the >original author, who had deliberately used the pejorative term "stupid >question." The term "stupid" has certain condescending connotations >that are not suggested by the relatively neutral term "inappropriate." >Perhaps those connotations had actually been deliberate, and not >coincidental, in which case changing the connotations could have >started a revision war, which I didn't want. > >I disagree with the cultural attitude suggested by the term "stupid >question." To me, there is no such thing as a "stupid question." If >somebody asks an inappropriate question, it should be sufficient just >not to answer the question, or to suggest an alternative question, >rather than to respond in a hostile or condescending manner. > >Nevertheless, this is just my personal opinion. Everybody is entitled >to an opinion. I didn't change the original wording, even though I >had to fight a desperate urge to do so, because I had thought that the >original author had just as much right to his/her wording as I did to >mine, and I wasn't sure if possibly changing the original intent, as >opposed to just the original wording, was appropriate. However, if I >had been the original author, I would have definitely worded the >sentence in a less elitist manner. > >-- Benjamin L. Russell ------------------------------ Message: 2 Date: Thu, 27 Nov 2008 14:22:13 +0100 From: Tillmann Rendel <[EMAIL PROTECTED]> Subject: Re: [Haskell-beginners] Re: Homework help (was Re: Help in Haskell) To: "Benjamin L.Russell" <[EMAIL PROTECTED]> Cc: beginners@haskell.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Benjamin L.Russell wrote: > I refrained from changing the page because of the possibility that the > original author may have been an elitist, who could have changed it > back immediately. > > [...] > > I could have risked going against the cultural attitude of the > original author, who had deliberately used the pejorative term "stupid > question." The term "stupid" has certain condescending connotations > that are not suggested by the relatively neutral term "inappropriate." > Perhaps those connotations had actually been deliberate, and not > coincidental, in which case changing the connotations could have > started a revision war, which I didn't want. > > [...] > > I wasn't sure if possibly changing the original intent, as opposed to > just the original wording, was appropriate. As I understand them, the point of a wiki in general and the Haskell wiki in particular is to involve readers with developing not only the wording, but also the content and underyling ideas of the texts. I would therefore consider changing the original intent as not generally inappropriate. Moreover, you do not start an edit war by editing, you start or continue an edit war by reverting again and again. If the original author decides to revert your change, you can still avoid an edit war by not reverting the revert. Tillmann ------------------------------ Message: 3 Date: Thu, 27 Nov 2008 23:40:57 +0530 From: "abdullah abdul Khadir" <[EMAIL PROTECTED]> Subject: [Haskell-beginners] Re: [Haskell] Re: Help : A problem with IO To: wman <[EMAIL PROTECTED]>, [EMAIL PROTECTED], [EMAIL PROTECTED] Cc: [EMAIL PROTECTED], beginners@haskell.org, [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset="iso-8859-1" Thanks all, I got it working finally. What did i learn ? a) I need to put a do after else for more than one instruction (?) b) All similar type of questions are to be redirected to haskell-beginner and haskell-cafe Points noted. Thank you once again, Abdullah Abdul Khadir On Wed, Nov 26, 2008 at 10:56 PM, wman <[EMAIL PROTECTED]> wrote: > if it should really read whole line, it must try to somehow chain the > values into the string / list of chars (using (:) ) > > getMyLine :: IO [Char] > getMyLine = do > c <- getChar > if (c == '\n') > then return "" -- imho [] looks nicer ;-) > else do > rest <- getMyLine > return $ c : rest > > -- or > > getMyLine :: IO [Char] > getMyLine = do > c <- getChar > if (c == '\n') > then return "" -- imho [] looks nicer ;-) > else getMyLine >>= return . (c:) > > -- or even shorter and still equivalent ;-) > > getMyLine :: IO [Char] > getMyLine = getChar >>= (\c -> if (c == '\n') then return [] else fmap > (c:) getMyLine) > > > > 2008/11/26 abdullah abdul Khadir <[EMAIL PROTECTED]> > >> Hi, >> >> The function getMyLine written by me is intended for getting a >> complete string from the standard input. >> >> import IO >> >> getMyLine :: IO [Char] >> getMyLine = do >> c <- getChar >> if(c == '\n') >> then return "" >> else cs <- getMyLine >> return [c] >> >> However I keep getting the following error: >> >> io.hs:14:2: Parse error in pattern >> Failed, modules loaded: none. >> >> I fail to understand what the error is. I tried out various things >> such as changing the alignment and so on to no avail. The following program, >> however, compiled successfully though it has the same structure as the >> previous program. >> >> checkd :: IO Bool >> checkd = do >> c <- getChar >> if(c=='d') >> then return True >> else return False >> >> Prelude> :load ./io.hs >> [1 of 1] Compiling Main ( io.hs, interpreted ) >> Ok, modules loaded: Main. >> *Main> checkd >> d >> True >> >> >> _______________________________________________ >> Haskell mailing list >> [EMAIL PROTECTED] >> http://www.haskell.org/mailman/listinfo/haskell >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20081127/d7715dac/attachment-0001.htm ------------------------------ Message: 4 Date: Fri, 28 Nov 2008 08:00:17 +0100 From: Janis Voigtlaender <[EMAIL PROTECTED]> Subject: [Haskell-beginners] ANNOUNCE: Haskell Communities and Activities Report (15th ed., November 2008) To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED], beginners@haskell.org, [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=us-ascii; format=flowed On behalf of the many, many contributors, I am pleased to announce that the Haskell Communities and Activities Report (15th edition, November 2008) http://www.haskell.org/communities/ is now available from the Haskell Communities home page in PDF and HTML formats. Many thanks go to all the people that contributed to this report, both directly, by sending in descriptions, and indirectly, by doing all the interesting things that are reported. I hope you will find it as interesting a read as I did. If you have not encountered the Haskell Communities and Activities Reports before, you may like to know that the first of these reports was published in November 2001. Their goal is to improve the communication between the increasingly diverse groups, projects, and individuals working on, with, or inspired by Haskell. The idea behind these reports is simple: Every six months, a call goes out to all of you enjoying Haskell to contribute brief summaries of your own area of work. Many of you respond (eagerly, unprompted, and sometimes in time for the actual deadline ;-) to the call. The editor collects all the contributions into a single report and feeds that back to the community. When I try for the next update, six months from now, you might want to report on your own work, project, research area or group as well. So, please put the following into your diaries now: ---------------------------------------- End of April 2009: target deadline for contributions to the May 2009 edition of the HC&A Report ---------------------------------------- Unfortunately, many Haskellers working on interesting projects are so busy with their work that they seem to have lost the time to follow the Haskell related mailing lists and newsgroups, and have trouble even finding time to report on their work. If you are a member, user or friend of a project so burdened, please find someone willing to make time to report and ask them to "register" with the editor for a simple e-mail reminder in April (you could point me to them as well, and I can then politely ask if they want to contribute, but it might work better if you do the initial asking). Of course, they will still have to find the ten to fifteen minutes to draw up their report, but maybe we can increase our coverage of all that is going on in the community. Feel free to circulate this announcement further in order to reach people who might otherwise not see it. Enjoy! Janis Voigtlaender <hcar at haskell.org> -- Dr. Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:[EMAIL PROTECTED] ------------------------------ Message: 5 Date: Fri, 28 Nov 2008 22:53:32 +0100 From: Torsten Otto <[EMAIL PROTECTED]> Subject: [Haskell-beginners] Wrapping random To: beginners@haskell.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Hi all, I teach a high school class in Computer Science. The current programming goal is to implement chat-bots, and we're using Haskell of course. Now one of my students had the seemingly easy idea of having the bot answer with a random sentence if it doesn't have "good" answer. Random in Haskell has its problems. I understand why you can't just call a function as you would in Java. I'm not firm enough with monads myself (and certainly don't want to go there in the class beyond I/O) so I'm calling for help here: Is there a way to wrap the generation of random numbers so that for the students it works like a function? We have this working: > import System.Random > main = > do randomNumber <- randomRIO (1::Int,2) > print (randomAnswer randomNumber) > randomAnswer r > | (r == 1) = "Nope!" > | (r == 2) = "Absolutely!" > | otherwise = "Error!" Now, how can we use it for something like this: >findAnswer [] = "h" >findAnswer (x:xs) > | (z == "unknown") = findAnswer xs > | otherwise = z > where z = findWord x lexikon where instead of getting "h" we'd like to call a function that would give us one of the strings out of randomAnswer. (findAnswer looks through a list [(keyword,response)]. I've looked at realworldhaskell and the wikibook among other sources, but I can't manage to piece anything useful together. How do I manage to get something of type IO to represent itself as a String? Any help would be greatly appreciated. Regards, Torsten Otto ------------------------------ Message: 6 Date: Sat, 29 Nov 2008 12:27:36 +1300 From: "Steven Ashley" <[EMAIL PROTECTED]> Subject: Re: [Haskell-beginners] Wrapping random Cc: beginners@haskell.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1 Hi Torsten, An option would be to use "randoms" to generate an infinite list of random numbers before hand and pass these numbers to your functions. Of course that will mean you have to keep track of what numbers you have used. Control.Monad.Random would take care of this stuff for you however it requires a simple understanding of monads. Best of luck, Steven 2008/11/29 Torsten Otto <[EMAIL PROTECTED]>: > Hi all, > > I teach a high school class in Computer Science. The current programming > goal is to implement chat-bots, and we're using Haskell of course. Now one > of my students had the seemingly easy idea of having the bot answer with a > random sentence if it doesn't have "good" answer. > > Random in Haskell has its problems. I understand why you can't just call a > function as you would in Java. I'm not firm enough with monads myself (and > certainly don't want to go there in the class beyond I/O) so I'm calling for > help here: Is there a way to wrap the generation of random numbers so that > for the students it works like a function? > > We have this working: > >> import System.Random > >> main = >> do randomNumber <- randomRIO (1::Int,2) >> print (randomAnswer randomNumber) > >> randomAnswer r >> | (r == 1) = "Nope!" >> | (r == 2) = "Absolutely!" >> | otherwise = "Error!" > > Now, how can we use it for something like this: > >>findAnswer [] = "h" >>findAnswer (x:xs) >> | (z == "unknown") = findAnswer xs >> | otherwise = z >> where z = findWord x lexikon > > where instead of getting "h" we'd like to call a function that would give us > one of the strings out of randomAnswer. > (findAnswer looks through a list [(keyword,response)]. > > I've looked at realworldhaskell and the wikibook among other sources, but I > can't manage to piece anything useful together. How do I manage to get > something of type IO to represent itself as a String? > > Any help would be greatly appreciated. > > Regards, > Torsten Otto > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 5, Issue 17 ****************************************