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: Issue installing reactive-banana-5.0.0.1 (Heinrich Apfelmus) 2. Re: Issue installing reactive-banana-5.0.0.1 (Miguel Negrao) 3. A wikipedia episode guide parser. [code review request] (Thomas Nickson) 4. Re: Issue installing reactive-banana-5.0.0.1 (Miguel Negrao) 5. Re: Haskell as a useful practical 'tool' for intelligent non-programmers (Miguel Negrao) ---------------------------------------------------------------------- Message: 1 Date: Sun, 06 May 2012 15:31:49 +0200 From: Heinrich Apfelmus <apfel...@quantentunnel.de> Subject: Re: [Haskell-beginners] Issue installing reactive-banana-5.0.0.1 To: beginners@haskell.org Message-ID: <jo5ug6$pd7$1...@dough.gmane.org> Content-Type: text/plain; charset=UTF-8; format=flowed Miguel Negrao wrote: > > Hum, that?s not exactly what I wanted. So if it?s the first event > just let it through, and then filter it. If it?s not the first event, > then do the inversion (1-x) or not depending on the last outputted > value, and then filter it. > > An input of > [[0.9],[0.5],[0.1],[0.9],[0.9]] > should produce > [[0.9],[],[0.9],[0.1],[0.9]] > > The following code is not correct but it?s closer to what I described: Ah, ok, then I don't understand your specification. Could you give a specification in terms of a simple list transformation example :: [Double] -> [Double] ? All list functions are allowed, we can then transform it into a style that uses only the combinators available in reactive-banana. Best regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com ------------------------------ Message: 2 Date: Sun, 6 May 2012 14:34:41 +0100 From: Miguel Negrao <miguel.negrao-li...@friendlyvirus.org> Subject: Re: [Haskell-beginners] Issue installing reactive-banana-5.0.0.1 To: beginners@haskell.org Message-ID: <ba022e24-3692-4659-b08c-ec7c3e7d2...@friendlyvirus.org> Content-Type: text/plain; charset=windows-1252 A 05/05/2012, ?s 15:26, Miguel Negrao escreveu: > > Hum, that?s not exactly what I wanted. So if it?s the first event just let it > through, and then filter it. If it?s not the first event, then do the > inversion (1-x) or not depending on the last outputted value, and then filter > it. > An input of > [[0.9],[0.5],[0.1],[0.9],[0.9]] > should produce > [[0.9],[],[0.9],[0.1],[0.9]] > > The following code is not correct but it?s closer to what I described: > > module Main where > > import Reactive.Banana > > main :: IO() > main = do > list <- interpretModel example [[0.9],[0.3],[0.4],[0.15],[0.87]] > putStrLn $ show list > > example :: Event t Double -> Event t Double > example e = filterede2 > where > filterede2 = filterE (\x->between x 0.0 0.2 && between x 0.8 1.0) e2 > e2 = f <$> bIsFirst <@> e <@> e2 > > bIsFirst = stepper True $ False <$ e > > between x a b = a < x && x < b > > f True x y = x > f False x y > | between y 0.8 1.0 = 1 - x > | otherwise = x Actually I just spotted that the filtering should not be done after the ?recursive? part. It should be something more like: > example e = e2 where e2 = filterE (\x->between x 0.0 0.2 && between x 0.8 > 1.0) (f <$> bIsFirst <@> e <@> e2) best, Miguel Negr?o ------------------------------ Message: 3 Date: Sun, 6 May 2012 19:07:16 +0100 From: Thomas Nickson <thomas.nick...@gmail.com> Subject: [Haskell-beginners] A wikipedia episode guide parser. [code review request] To: Beginners@haskell.org Message-ID: <can-dxbxpz-zuzzogz9q_crdeqatpb-x5w4owcrtucmgwskd...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" I have written my first piece of haskell code which I'm, to be honest, not too proud of. I have used the tag soup library to parse and manipulate the wikipedia episode list page such as: http://en.wikipedia.org/wiki/List_of_Weeds_episodes to scrape some of the episode information and place it in to a series of data structures. Nothing too complicated. I know there are probably better libraries out there, I know of HXT and others but it uses arrows and I want to start getting to know the basics before moving on to that. The main point here being that I'm not to interested in the library I used but the code I produced with it. My main concern is in the layout of the code. It needs to keep state and I'm aware of the state monad but is it a good idea to push all of the code in to the state monad and restructure it that way or is that too complex for what I do. I'm not really sure how else I could refactor it but any suggestions on how to improve would be great. The code is here: http://pastebin.com/409SLPre Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20120506/3b52cd14/attachment-0001.htm> ------------------------------ Message: 4 Date: Sun, 6 May 2012 20:35:19 +0100 From: Miguel Negrao <miguel.negrao-li...@friendlyvirus.org> Subject: Re: [Haskell-beginners] Issue installing reactive-banana-5.0.0.1 To: beginners@haskell.org Message-ID: <d4510fb6-c560-4f93-9268-54b07c6fd...@friendlyvirus.org> Content-Type: text/plain; charset=iso-8859-1 A 06/05/2012, ?s 14:31, Heinrich Apfelmus escreveu: > Ah, ok, then I don't understand your specification. > > Could you give a specification in terms of a simple list transformation > > example :: [Double] -> [Double] > > ? All list functions are allowed, we can then transform it into a style that > uses only the combinators available in reactive-banana. Ok, this should demonstrate an example of what I mean: module Main where main :: IO() main = print $ test [0.9,0.1,0.2,0.8] --should output [0.9,0.1,0.8,0.8] test :: [Double]->[Double] test (x:xs) = x : test1 xs x test [] = [] test1:: [Double]->Double->[Double] test1 (x:xs) lastValue = let y = if lastValue>=0.8 then x else 1.0-x in if (y<=0.2) || (y>=0.8) then y : test1 xs y else test1 xs lastValue test1 [] _ = [] best, Miguel Negr?o ------------------------------ Message: 5 Date: Sun, 6 May 2012 20:49:57 +0100 From: Miguel Negrao <miguel.negrao-li...@friendlyvirus.org> Subject: Re: [Haskell-beginners] Haskell as a useful practical 'tool' for intelligent non-programmers To: beginners@haskell.org Message-ID: <c7e6aebf-2fea-4eed-b1ac-7fa5fa771...@friendlyvirus.org> Content-Type: text/plain; charset=windows-1252 A 29/04/2012, ?s 19:43, Ertugrul S?ylemez escreveu: > Hello there, > > actually I did not want to participate in this discussion, but as I have > experience teaching many programming languages to many different sorts > of people, I feel obligated to share my observations. > > To someone marginally skilled at logical thinking Haskell appears to be > the first choice as the first programming language. I'm offering two > experiences as a reference: > > * I had to teach C++ to a math student. The language was very hard to > grasp, because as someone with math skills you practically have to > go back to stone age. Instead of writing equations and > relationships you have to imagine yourself sitting before a large > array of little slips of paper and manipulate them arithmetically to > reach the goal you want. Remember that the array is your memory. > You don't have a brain in C++. This was about the most difficult > part and the whole thing turned out to be a very frustrating > endeavor, because you basically have to temporarily forget what you > learned in university. Yes ! As someone who studied pure maths for 6 years, Haskell seems so natural and elegant to me, yet so alien to about everyone else I know that are very good coders already in other languages. When I?m reading about Haskell, I?m constantly like ?yeah, that?s like it?s done in mathematics !?, the type of discourse is the same, the same relentless obsession with finding more general models of things, getting what are the fundamental properties of something and then generalizing (what is an open set ? -> topology, what is summing ? group theory, algebras, etc ) until you hit the stratosphere (category theory...). Specially since discovering functional programming I have a hard time coding in imperative languages because my times studying math refined my taste for elegance and I find it quite rare to find elegance or beauty in imperative code, where I find it a lot in functional code. In the end for me it has really become an aesthetic choice. This is such an insightful post ! Thanks ! best, Miguel Negr?o ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 47, Issue 8 ****************************************