Re: [Haskell-cafe] How to implement the mean function

2011-07-01 Thread aditya siram
What compiler errors are you getting? -deech On Fri, Jul 1, 2011 at 12:55 AM, Ruohao Li liruo...@gmail.com wrote: Hi guys, I just started learning some Haskell. I want to implement a mean function to compute the mean of a list. The signature of the function is: mean :: (Num a, Fractional b) =

Re: [Haskell-cafe] How to implement the mean function

2011-07-01 Thread Ruohao Li
For mean xs = sum xs / length xs, I got the following: test.hs:8:10: No instance for (Fractional Int) arising from a use of `/' at test.hs:8:10-27 Possible fix: add an instance declaration for (Fractional Int) In the expression: sum xs / length xs In the definition of

Re: [Haskell-cafe] How to implement the mean function

2011-07-01 Thread Nathan Howell
(/) operates on a Fractional instance... but length returns an Int, which is not a Fractional. You can convert the Int to a Fractional instance: mean xs = sum xs / fromIntegral (length xs) or try an integer division: mean xs = sum xs `div` length xs -n On Thu, Jun 30, 2011 at 10:55 PM, Ruohao

Re: [Haskell-cafe] How to implement the mean function

2011-07-01 Thread Ruohao Li
For mean xs = sum xs / fromIntegral (length xs), I got the following: test.hs:8:10: Could not deduce (Fractional a) from the context (Num a, Fractional b) arising from a use of `/' at test.hs:8:10-42 Possible fix: add (Fractional a) to the context of the type signature

Re: [Haskell-cafe] How to implement the mean function

2011-07-01 Thread Jack Henahan
Additionally, this SO question[0] is nearly identical, and provides a little more elaboration. [0]:http://stackoverflow.com/questions/2376981/haskell-types-frustrating-a-simple-average-function On Jul 1, 2011, at 2:07 AM, Ruohao Li wrote: For mean xs = sum xs / length xs, I got the following:

Re: [Haskell-cafe] How to implement the mean function

2011-07-01 Thread Lyndon Maydwell
The problem is that you need to convert (length xs) to a Num, then return a Fractional. On Fri, Jul 1, 2011 at 2:07 PM, Nathan Howell nathan.d.how...@gmail.com wrote: (/) operates on a Fractional instance... but length returns an Int, which is not a Fractional. You can convert the Int to a

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread dm-list-haskell-cafe
At Fri, 1 Jul 2011 09:39:32 +0400, Eugene Kirpichov wrote: Hi, I'm rewriting timeplot to avoid holding the whole input in memory, and naturally a problem arises: How to represent large but finite streams and functions that process them, returning other streams or some kinds of aggregate

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Heinrich Apfelmus
Eugene Kirpichov wrote: I'm rewriting timeplot to avoid holding the whole input in memory, and naturally a problem arises: How to represent large but finite streams and functions that process them, returning other streams or some kinds of aggregate values? Examples: * Adjacent differences of

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Eugene Kirpichov
Plain old lazy lists do not allow me to combine multiple concurrent computations, e.g. I cannot define average from sum and length. 2011/7/1 Heinrich Apfelmus apfel...@quantentunnel.de: Eugene Kirpichov wrote: I'm rewriting timeplot to avoid holding the whole input in memory, and naturally a

Re: [Haskell-cafe] How to implement the mean function

2011-07-01 Thread Ruohao Li
Thanks for the SO link, change the Num a constraint to Real a and using realToFrac then it just works. On Fri, Jul 1, 2011 at 2:11 PM, Jack Henahan jhena...@uvm.edu wrote: Additionally, this SO question[0] is nearly identical, and provides a little more elaboration. [0]:

[Haskell-cafe] compare iteratee with python's yield

2011-07-01 Thread yi huang
I just read several tutorials on iteratee, i find that iteratee is similar to python's generator, both allow streamlined data processing. For example, i can implement enumFile and printChunks in python like this: EOF = None def enum_file(bufsize, filename): with open(filename) as

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Malcolm Wallace
Sure you can. runningAverage :: Int - [Double] - [Double] runningAverage n xs = let chunk = take n xs in (sum chunk / length chunk) : runningAverage (tail xs) Lazy lists are absolutely ideal for this purpose. Regards, Malcolm On 1 Jul 2011, at 07:33, Eugene Kirpichov

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Eugene Kirpichov
I meant the average of the whole list - given a sumS and lengthS (S for Stream), write meanS as something like liftS2 (/) sumS lengthS. Or is that possible with lazy lists too? (looks like arrows actually - which arrow is appropriate here?) 2011/7/1 Malcolm Wallace malcolm.wall...@me.com: Sure

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Alexey Khudyakov
On Fri, Jul 1, 2011 at 12:21 PM, Eugene Kirpichov ekirpic...@gmail.com wrote: I meant the average of the whole list - given a sumS and lengthS (S for Stream), write meanS as something like liftS2 (/) sumS lengthS. Or is that possible with lazy lists too? Sure you can. Sum, length and mean

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Eugene Kirpichov
Alexey, your definition of mean does not look like liftS2 (/) sum length - you have to manually fuse these computations. I'm asking for a formalism that does this fusion automatically (and guaranteedly). 2011/7/1 Alexey Khudyakov alexey.sklad...@gmail.com: On Fri, Jul 1, 2011 at 12:21 PM,

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Alexey Khudyakov
On Fri, Jul 1, 2011 at 12:54 PM, Eugene Kirpichov ekirpic...@gmail.com wrote: Alexey, your definition of mean does not look like liftS2 (/) sum length - you have to manually fuse these computations. Well it was fused for numerical stability I'm asking for a formalism that does this fusion

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Heinrich Apfelmus
Eugene Kirpichov wrote: Plain old lazy lists do not allow me to combine multiple concurrent computations, e.g. I cannot define average from sum and length. I meant the average of the whole list - given a sumS and lengthS (S for Stream), write meanS as something like liftS2 (/) sumS lengthS.

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Eugene Kirpichov
Thanks but I'm afraid that's still not quite what I'm looking for; guess I'll have to define my desire by my implementation - so once it's ready I'll show the result to cafe :) 2011/7/1 Alexey Khudyakov alexey.sklad...@gmail.com: On Fri, Jul 1, 2011 at 12:54 PM, Eugene Kirpichov

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread John Lato
From: Eugene Kirpichov ekirpic...@gmail.com Subject: [Haskell-cafe] Patterns for processing large but finite streams To: Haskell Cafe haskell-cafe@haskell.org Message-ID: banlktikdsvq2wv4wjr+qmuvksoav0kt...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 Hi, I'm

Re: [Haskell-cafe] compare iteratee with python's yield

2011-07-01 Thread Ertugrul Soeylemez
yi huang yi.codepla...@gmail.com wrote: I just read several tutorials on iteratee, i find that iteratee is similar to python's generator, both allow streamlined data processing. For example, i can implement enumFile and printChunks in python like this: EOF = None def

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread John Lato
After the list discussion, I'm surprised nobody mentioned Max Rabkin/Conal Elliott's blog posts on folds and zips. http://squing.blogspot.com/2008/11/beautiful-folding.html http://conal.net/blog/posts/enhancing-a-zip/ They develop a formalism for zipping functions on lists. Iteratee's `zip` set

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Eugene Kirpichov
Hi, You're right, reifying stream processing functions seems indeed the way to go - and that looks even more like arrows :) I thought of something like this: data SP i o = Yield [o] (Maybe (Maybe i - SP i o)) Scalar functions like sum and length are just SP's that return a single item in the

Re: [Haskell-cafe] Printing the empty list.

2011-07-01 Thread Ryan Ingram
Figuring out how to tell what type ghci is defaulting to was an interesting exercise. The sum [] trick seemed cool, so I tried a variant: Prelude let f xs = const xs $ show xs Prelude f [] [] Prelude :t it it :: [()] -- ryan On Thu, Jun 30, 2011 at 6:44 PM, Ivan Lazar Miljenovic

[Haskell-cafe] NLP libraries and tools?

2011-07-01 Thread Dmitri O.Kondratiev
Hi, Please advise on NLP libraries similar to Natural Language Toolkit ( www.nltk.org) First of all I need: - tools to construct 'bag of words' ( http://en.wikipedia.org/wiki/Bag_of_words_model), which is a list of words in the article. - tools to prune common words, such as prepositions and

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Ketil Malde
Eugene Kirpichov ekirpic...@gmail.com writes: 2011/7/1 Heinrich Apfelmus apfel...@quantentunnel.de: Eugene Kirpichov wrote: I'm rewriting timeplot to avoid holding the whole input in memory, and naturally a problem arises: Plain old lazy lists? Heretic! :-) I generally have written a

Re: [Haskell-cafe] Patterns for processing large but finite streams

2011-07-01 Thread Erik Hesselink
This sound exactly like what attribute grammars, like the system developed at Utrecht University [1], are useful for. Erik [1] http://www.cs.uu.nl/wiki/HUT/AttributeGrammarSystem On Fri, Jul 1, 2011 at 10:54, Eugene Kirpichov ekirpic...@gmail.com wrote: Alexey, your definition of mean does not

[Haskell-cafe] Is there Functor instance of Enumerator'

2011-07-01 Thread yi huang
Say i want to compose Enumerator ByteString m b and Iteratee Builder m b, so I try to transform the enum to Enumerator Builder m b, providing function ByteString - Builder. It's like implement a Functor instance for Enumerator. But i failed, there are no way to make type system happy. Am I right

[Haskell-cafe] Twitter API?

2011-07-01 Thread Dmitri O.Kondratiev
Hi, Does anybody work with any Haskell Twitter API library? In particular supporting OAuth authentication? Thanks! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Twitter API?

2011-07-01 Thread Michael Snoyman
On Fri, Jul 1, 2011 at 5:56 PM, Dmitri O.Kondratiev doko...@gmail.com wrote: Hi, Does anybody work with any Haskell Twitter API library? In particular supporting OAuth  authentication? Thanks! Hi, Horimi Ishii added support for OAuth/Twitter to the authenticate[1] package. Michael [1]

Re: [Haskell-cafe] Twitter API?

2011-07-01 Thread Dmitri O.Kondratiev
On Fri, Jul 1, 2011 at 6:59 PM, Michael Snoyman mich...@snoyman.com wrote: On Fri, Jul 1, 2011 at 5:56 PM, Dmitri O.Kondratiev doko...@gmail.com wrote: Hi, Does anybody work with any Haskell Twitter API library? In particular supporting OAuth authentication? Thanks! Hi, Horimi

Re: [Haskell-cafe] NLP libraries and tools?

2011-07-01 Thread Rogan Creswick
On Fri, Jul 1, 2011 at 3:31 AM, Dmitri O.Kondratiev doko...@gmail.com wrote: Hi, Please advise on NLP libraries similar to Natural Language Toolkit There is a (slowly?) growing NLP community for haskell over at: http://projects.haskell.org/nlp/ The nlp mailing list may be a better place to

Re: [Haskell-cafe] Is there Functor instance of Enumerator'

2011-07-01 Thread Alexander Solla
On Fri, Jul 1, 2011 at 7:38 AM, yi huang yi.codepla...@gmail.com wrote: Say i want to compose Enumerator ByteString m b and Iteratee Builder m b, so I try to transform the enum to Enumerator Builder m b, providing function ByteString - Builder. It's like implement a Functor instance for

[Haskell-cafe] Haskell and Databases

2011-07-01 Thread Tobias Schoofs
I am studying Haskell database libraries. In particular I am looking at haskelldb and the Takusen Database.Enumerator library. In haskelldb, there are very good ideas aiming to represent database objects as (typeable) Haskell objects, instead of embedding SQL in plain strings. This is really

Re: [Haskell-cafe] Haskell and Databases

2011-07-01 Thread Yves P----
There is something that bothers me with that text, I can't get to grasp what it is... 2011/7/1 Tobias Schoofs tobias.scho...@gmx.net ** I am studying Haskell database libraries. In particular I am looking at haskelldb and the Takusen Database.Enumerator library. In haskelldb, there are

Re: [Haskell-cafe] Haskell and Databases

2011-07-01 Thread Christopher Done
On 1 July 2011 20:51, Yves P limestr...@gmail.com wrote: There is something that bothers me with that text, I can't get to grasp what it is... It's bigger than Godzilla? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Haskell and Databases

2011-07-01 Thread Jack Henahan
'Courier New, 18pt' considered harmful? On Jul 1, 2011, at 3:08 PM, Christopher Done wrote: On 1 July 2011 20:51, Yves P limestr...@gmail.com wrote: There is something that bothers me with that text, I can't get to grasp what it is... It's bigger than Godzilla?

Re: [Haskell-cafe] Haskell and Databases

2011-07-01 Thread Miguel Mitrofanov
HTML emails considered harmful. On 1 Jul 2011, at 23:17, Jack Henahan wrote: 'Courier New, 18pt' considered harmful? On Jul 1, 2011, at 3:08 PM, Christopher Done wrote: On 1 July 2011 20:51, Yves P limestr...@gmail.com wrote: There is something that bothers me with that text, I can't

Re: [Haskell-cafe] Haskell and Databases

2011-07-01 Thread Greg Weber
Hi Tobias, Have you seen DSH [1]? You might also be interested in Persistent [2], but it sounds like it has different goals than what you are after. [1] http://hackage.haskell.org/package/DSH [2] http://www.yesodweb.com/book/persistent ___ Haskell-Cafe

Re: [Haskell-cafe] NLP libraries and tools?

2011-07-01 Thread Dmitri O.Kondratiev
On Fri, Jul 1, 2011 at 9:34 PM, Rogan Creswick cresw...@gmail.com wrote: On Fri, Jul 1, 2011 at 3:31 AM, Dmitri O.Kondratiev doko...@gmail.com wrote: First of all I need: ... - tools to construct 'bag of words' (http://en.wikipedia.org/wiki/Bag_of_words_model), which is a list of words

Re: [Haskell-cafe] NLP libraries and tools?

2011-07-01 Thread Rogan Creswick
On Fri, Jul 1, 2011 at 12:38 PM, Dmitri O.Kondratiev doko...@gmail.com wrote: On Fri, Jul 1, 2011 at 9:34 PM, Rogan Creswick cresw...@gmail.com wrote: On Fri, Jul 1, 2011 at 3:31 AM, Dmitri O.Kondratiev doko...@gmail.com wrote: First of all I need: Unfortunately 'cabal install' fails with

[Haskell-cafe] Parsing cabal files to calculate average number of dependencies

2011-07-01 Thread Gwern Branwen
Athas on #haskell wondered how many dependencies the average Haskell package had. I commented that it seemed like some fairly simple scripting to find out, and as these things tend to go, I wound up doing a complete solution myself. First, we get most/all of Hackage locally to examine, as

Re: [Haskell-cafe] Haskell and Databases

2011-07-01 Thread Tobias Schoofs
Sorry for the awful message format in the first try! I am studying Haskell database libraries. In particular I am looking at haskelldb and the Takusen Database.Enumerator library. In haskelldb, there are very good ideas aiming to represent database objects as (typeable) Haskell objects,

Re: [Haskell-cafe] Parsing cabal files to calculate average number of dependencies

2011-07-01 Thread Gwern Branwen
On Fri, Jul 1, 2011 at 4:49 PM, L Corbijn aspergesoe...@gmail.com wrote: Is this including or exluding 'or'-ed dependency lists like http://hackage.haskell.org/package/hugs2yc ? Excluding, it seems. When I run the script on that tarball: $ tar --wildcards *.cabal -Oxf `find . -name *.tar.gz |

Re: [Haskell-cafe] Parsing cabal files to calculate average number of dependencies

2011-07-01 Thread Rogan Creswick
On Fri, Jul 1, 2011 at 1:43 PM, Gwern Branwen gwe...@gmail.com wrote: Athas on #haskell wondered how many dependencies the average Haskell package had. I commented that it seemed like some fairly simple scripting to find out, and as these things tend to go, I wound up doing a complete solution

[Haskell-cafe] ANNOUNCE: Hs2lib-0.4.8

2011-07-01 Thread Phyx
What is it? A preprocessor and library which allow you to create dynamic libs from arbitrary annotated Haskell programs with one click. It also allows you to use the generated lib in C, C++ and C# just by including the generated header files. At a minimum it can be considered the

Re: [Haskell-cafe] Parsing cabal files to calculate average number of dependencies

2011-07-01 Thread Gwern Branwen
On Fri, Jul 1, 2011 at 5:23 PM, Rogan Creswick cresw...@gmail.com wrote: I think the index tarball has all the info you need, and would be faster to retrieve / process, if you or anyone else needs to get the .cabal files again: http://hackage.haskell.org/packages/archive/00-index.tar.gz

Re: [Haskell-cafe] NLP libraries and tools?

2011-07-01 Thread Dmitri O.Kondratiev
On Fri, Jul 1, 2011 at 11:58 PM, Rogan Creswick cresw...@gmail.com wrote: On Fri, Jul 1, 2011 at 12:38 PM, Dmitri O.Kondratiev doko...@gmail.com wrote: On Fri, Jul 1, 2011 at 9:34 PM, Rogan Creswick cresw...@gmail.com wrote: On Fri, Jul 1, 2011 at 3:31 AM, Dmitri O.Kondratiev

Re: [Haskell-cafe] NLP libraries and tools?

2011-07-01 Thread Rogan Creswick
On Fri, Jul 1, 2011 at 2:52 PM, Dmitri O.Kondratiev doko...@gmail.com wrote: Any other then 'toktok' Haskell word tokenizer that compiles and works? I need something like: http://nltk.googlecode.com/svn/trunk/doc/api/nltk.tokenize.regexp.WordPunctTokenizer-class.html I don't think this exists

Re: [Haskell-cafe] ANNOUNCE: Hs2lib-0.4.8

2011-07-01 Thread Yves Parès
This is interesting, From what I can see, you can automatically mashall haskell datatypes into C structs. Are there portable libraries that do that ? Or do you do this by yourself ? 2011/7/1 Phyx loneti...@gmail.com What is it? A preprocessor and library which allow you to create

Re: [Haskell-cafe] Parsing cabal files to calculate average number of dependencies

2011-07-01 Thread Gwern Branwen
Another thing you can do along the same lines is generate a script to download all the repos from packages which declare repos. Some ugly code: import Data.Maybe (fromJust) import Distribution.PackageDescription import Distribution.PackageDescription.Parse import Control.Monad (unless) main ::

[Haskell-cafe] Lambdabot plugin system description

2011-07-01 Thread Richard Wallace
Hey all, I'm curious if there are any papers or anything else describing the plugin system in Lambdabot. If not I'll dig through the code, but my Haskell isn't yet that strong so a higher level introduction would be very helpful. Thanks, Rich ___

Re: [Haskell-cafe] Lambdabot plugin system description

2011-07-01 Thread Don Stewart
In fact there is! Plugging Haskell In. André Pang, Don Stewart, Sean Seefried, and Manuel M. T. Chakravarty. In Proceedings of the ACM SIGPLAN Workshop on Haskell, pages 10-21. ACM Press, 2004 http://www.cse.unsw.edu.au/~dons/papers/hs-plugins.pdf And Dynamic Applications From the Ground Up.

Re: [Haskell-cafe] compare iteratee with python's yield

2011-07-01 Thread Casey McCann
On Fri, Jul 1, 2011 at 6:01 AM, Ertugrul Soeylemez e...@ertes.de wrote: I don't know Python very well, but I suspect that its generators are really a sort of coroutines.  Iteratees are also coroutines, but their architecture is quite different. Python generators were originally a sort of

Re: [Haskell-cafe] Lambdabot plugin system description

2011-07-01 Thread Richard Wallace
Awesome, thanks! That looks really useful. On Fri, Jul 1, 2011 at 7:45 PM, Don Stewart don...@gmail.com wrote: In fact  there is! Plugging Haskell In. André Pang, Don Stewart, Sean Seefried, and Manuel M. T. Chakravarty. In Proceedings of the ACM SIGPLAN Workshop on Haskell, pages 10-21.