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) =
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
(/) 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
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
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:
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
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
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
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
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]:
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
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
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
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
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,
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
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.
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
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
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
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
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
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
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
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
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
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
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
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]
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
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
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
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
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
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
'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?
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
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
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
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
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
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,
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 |
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
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
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
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
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
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
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 ::
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
___
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.
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
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.
54 matches
Mail list logo