[Haskell-cafe] Lazy vs correct IO [Was: A round of golf]

2008-09-19 Thread oleg
Lennart Augustsson wrote main = do name:_ - getArgs file - readFile name print $ length $ lines file Given the stance against top-level mutable variables, I have not expected to see this Lazy IO code. After all, what could be more against the spirit of Haskell than a `pure'

Re: [Haskell-cafe] Lazy vs correct IO [Was: A round of golf]

2008-09-19 Thread Don Stewart
oleg: Given the stance against top-level mutable variables, I have not expected to see this Lazy IO code. After all, what could be more against the spirit of Haskell than a `pure' function with observable side effects. With Lazy IO, one indeed has to choose between correctness and

[Haskell-cafe] Re: Library design question

2008-09-19 Thread apfelmus
Andre Nathan wrote: I'm trying to write a simple graph library for a project of mine There's also Martin Erwig's functional graph library in Data.Graph.Inductive ( fgl on hackage). Regards, apfelmus ___ Haskell-Cafe mailing list

[Haskell-cafe] Re: Library design question

2008-09-19 Thread Christian Maeder
Duncan Coutts wrote: On Thu, 2008-09-18 at 15:43 -0300, Andre Nathan wrote: My Graph type is the following. data Graph a b = Graph { adjacencies :: Map Int (a, (Map Int b)) , numVertices :: Int , numEdges:: Int } addVertex :: Int - a - State (Graph a b) ()

Re: [Haskell-cafe] A round of golf

2008-09-19 Thread Ketil Malde
Don Stewart [EMAIL PROTECTED] writes: If I want to make my own efficient bytestring consumer, is that what I need to use in order to preserve the inherent laziness of the datastructure? you can get foldChunks from Data.ByteString.Lazy.Internal, or write your own chunk folder. IME you can

Re: [Haskell-cafe] A round of golf

2008-09-19 Thread Ketil Malde
Creighton Hogg [EMAIL PROTECTED] writes: To ask an overly general question, if lazy bytestring makes a nice provider for incremental processing are there reasons to _not_ reach for that as my default when processing large files? I think it is a nice default. I'd reach for strict

[Haskell-cafe] Updated formlets sample?

2008-09-19 Thread Martin Huschenbett
Hi all, I found a blog post concerning formlets [1] in the web. Since looks very interesting I tried to compile the sample code with recent versions of HAppS and formlets from hackage. But this didn't work as the API of formlets has changed since this post. I tried to adopt the code to the

Re: [Haskell-cafe] Lazy vs correct IO

2008-09-19 Thread Ketil Malde
[EMAIL PROTECTED] writes: It is interesting to compare the above main function with the corresponding lazy IO: Minor point I know, but aren't you really comparing it with the corresponding *strict* IO? main'' = do names - getArgs files - mapM readFile names

Re: [Haskell-cafe] control-timeout with gtk

2008-09-19 Thread Marco Túlio Gontijo e Silva
Em Qui, 2008-09-18 às 16:14 -0300, Marco Túlio Gontijo e Silva escreveu: Em Qui, 2008-09-18 às 11:51 -0700, Adam Langley escreveu: Do you want control-timeout? I think control-timeout is very useful. I'll try to fix it, and if I could, I'll upload it to hackage then. I couldn't, and I

Re: [Haskell-cafe] control-timeout with gtk

2008-09-19 Thread Marco Túlio Gontijo e Silva
Hello, Em Qui, 2008-09-18 às 10:05 -0700, Judah Jacobson escreveu: Just a guess, but this might be a problem with control-timeout's use of the unsafePerformIO global variables hack. It's missing the standard NOINLINE annotations which prevent multiple copies of the global variable from being

Re: [Haskell-cafe] Lazy vs correct IO [Was: A round of golf]

2008-09-19 Thread Kim-Ee Yeoh
oleg-30 wrote: I have not expected to see this Lazy IO code. After all, what could be more against the spirit of Haskell than a `pure' function with observable side effects. What could even be more against the spirit of Haskell than the original theme of this thread, i.e. code that

Re: [Haskell-cafe] Lazy vs correct IO [Was: A round of golf]

2008-09-19 Thread Lennart Augustsson
I agree that lazy IO is a can with some worms in it. But it's not that strange. The readFile operation is in the IO monad, so it has an effect on the world. This effect is not finished when readFile returns, and from the world point of view it's not entirely deterministic. On Fri, Sep 19, 2008

[Haskell-cafe] lazy strings and parallel read

2008-09-19 Thread Manlio Perillo
Hi. After having read http://book.realworldhaskell.org/read/concurrent-and-multicore-programming.html#id676390 I have a doubt about Data.ByteString.Lazy. Why getContents function don't use pread (or an emulation, if not available)? Thanks Manlio Perillo

[Haskell-cafe] ANNOUNCE: Extensible and Modular Generics for the Masses (EMGM) 0.1

2008-09-19 Thread Sean Leather
Extensible and Modular Generics for the Masses == Extensible and Modular Generics for the Masses (EMGM) is a library for generic programming in Haskell using type classes. This is the initial release of a maintained library for EMGM. Other versions

Re: [Haskell-cafe] lazy strings and parallel read

2008-09-19 Thread Don Stewart
manlio_perillo: Hi. After having read http://book.realworldhaskell.org/read/concurrent-and-multicore-programming.html#id676390 I have a doubt about Data.ByteString.Lazy. Why getContents function don't use pread (or an emulation, if not available)? Why would it? -- Don

[Haskell-cafe] performance of map reduce

2008-09-19 Thread Manlio Perillo
Hi again. In http://book.realworldhaskell.org/read/concurrent-and-multicore-programming.html#id676390 there is a map reduce based log parser. I have written an alternative version: http://paste.pocoo.org/show/85699/ but, with a file of 315 MB, I have [1]: 1) map reduce implementation, non

Re: [Haskell-cafe] lazy strings and parallel read

2008-09-19 Thread Manlio Perillo
Don Stewart ha scritto: manlio_perillo: Hi. After having read http://book.realworldhaskell.org/read/concurrent-and-multicore-programming.html#id676390 I have a doubt about Data.ByteString.Lazy. Why getContents function don't use pread (or an emulation, if not available)? Why would it?

Re: [Haskell-cafe] lazy strings and parallel read

2008-09-19 Thread Manlio Perillo
Manlio Perillo ha scritto: Hi. After having read http://book.realworldhaskell.org/read/concurrent-and-multicore-programming.html#id676390 I have a doubt about Data.ByteString.Lazy. Why getContents function don't use pread (or an emulation, if not available)? A correction. getContents

Re: [Haskell-cafe] lazy strings and parallel read

2008-09-19 Thread Duncan Coutts
On Fri, 2008-09-19 at 18:46 +0200, Manlio Perillo wrote: Don Stewart ha scritto: manlio_perillo: Hi. After having read http://book.realworldhaskell.org/read/concurrent-and-multicore-programming.html#id676390 I have a doubt about Data.ByteString.Lazy. Why getContents function

Re: [Haskell-cafe] performance of map reduce

2008-09-19 Thread Don Stewart
manlio_perillo: Hi again. In http://book.realworldhaskell.org/read/concurrent-and-multicore-programming.html#id676390 there is a map reduce based log parser. I have written an alternative version: http://paste.pocoo.org/show/85699/ but, with a file of 315 MB, I have [1]: 1) map

Re: [Haskell-cafe] lazy strings and parallel read

2008-09-19 Thread Manlio Perillo
Duncan Coutts ha scritto: On Fri, 2008-09-19 at 18:46 +0200, Manlio Perillo wrote: Don Stewart ha scritto: manlio_perillo: Hi. After having read http://book.realworldhaskell.org/read/concurrent-and-multicore-programming.html#id676390 I have a doubt about Data.ByteString.Lazy. Why

Re: [Haskell-cafe] Lazy vs correct IO [Was: A round of golf]

2008-09-19 Thread Jonathan Cast
On Fri, 2008-09-19 at 16:30 +0100, Lennart Augustsson wrote: I agree that lazy IO is a can with some worms in it. But it's not that strange. The readFile operation is in the IO monad, so it has an effect on the world. This effect is not finished when readFile returns, and from the world

Re: [Haskell-cafe] lazy strings and parallel read

2008-09-19 Thread Duncan Coutts
On Fri, 2008-09-19 at 19:50 +0200, Manlio Perillo wrote: But if every function that reads the data uses pread, then this should no more be a problem. Or I'm missing some other thing? If you used something like pread instead of hGetContents then yes that would not involve semi-closing a

Re[2]: [Haskell-cafe] performance of map reduce

2008-09-19 Thread Bulat Ziganshin
Hello Don, Friday, September 19, 2008, 9:12:43 PM, you wrote: It is possible to implement a map reduce version that can handle gzipped log files? Using the zlib binding on hackage.haskell.org, you can stream multiple zlib decompression threads with lazy bytestrings, and combine the

Re: [Haskell-cafe] Lazy vs correct IO [Was: A round of golf]

2008-09-19 Thread David Menendez
On Fri, Sep 19, 2008 at 2:51 AM, [EMAIL PROTECTED] wrote: Lennart Augustsson wrote main = do name:_ - getArgs file - readFile name print $ length $ lines file Given the stance against top-level mutable variables, I have not expected to see this Lazy IO code. After all, what

Re: [Haskell-cafe] Hackage and HaXml situation

2008-09-19 Thread John Goerzen
Duncan Coutts wrote: On Thu, 2008-09-18 at 15:32 -0500, John Goerzen wrote: Basically for each package we have an optional suggested version constraint. This would be used in the hackage website to direct people That would solve the problem nicely, I think. Do you have an ETA for this

[Haskell-cafe] Re: Library design question

2008-09-19 Thread Andre Nathan
On Fri, 2008-09-19 at 10:35 +0200, Christian Maeder wrote: I agree. Duncan's version also looks more atomic to me, [...] OK, so what I have now is addVertex :: Int - a - Graph a b - Graph a b addVertex v l g = Graph adj (numVertices g + 1) (numEdges g) where adj = Map.insert v (l,

Re: [Haskell-cafe] Re: Library design question

2008-09-19 Thread Andre Nathan
On Fri, 2008-09-19 at 09:51 +0200, apfelmus wrote: There's also Martin Erwig's functional graph library in Data.Graph.Inductive ( fgl on hackage). I tried it some time ago, but for large graphs it has a very high memory usage. Best, Andre ___

Re: [Haskell-cafe] control-timeout with gtk

2008-09-19 Thread Thomas M. DuBuisson
On Fri, 2008-09-19 at 09:09 -0300, Marco Túlio Gontijo e Silva wrote: I added the NOINLINE annotations and even tried building with -fno-cse, but the result was the same. Do you have any other suggestions? A while ago I made a shim using control-event to provide the control-timeout api in

Re: [Haskell-cafe] Re: Python's big challenges, Haskell's big advantages?

2008-09-19 Thread Manlio Perillo
Brandon S. Allbery KF8NH ha scritto: On Sep 18, 2008, at 15:10 , Manlio Perillo wrote: Allocation areas are per-CPU, not per-thread. A Concurrent Haskell thread consists of a TSO (thread state object, currently 11 machine words), and a stack, which we currently start with 1KB and grow on

Re: [Haskell-cafe] Re: Library design question

2008-09-19 Thread Daniel Fischer
Am Freitag, 19. September 2008 22:55 schrieb Andre Nathan: On Fri, 2008-09-19 at 10:35 +0200, Christian Maeder wrote: I agree. Duncan's version also looks more atomic to me, [...] OK, so what I have now is addVertex :: Int - a - Graph a b - Graph a b addVertex v l g = Graph adj

Re: [Haskell-cafe] performance of map reduce

2008-09-19 Thread Manlio Perillo
Don Stewart ha scritto: manlio_perillo: [...] It is possible to implement a map reduce version that can handle gzipped log files? Using the zlib binding on hackage.haskell.org, you can stream multiple zlib decompression threads with lazy bytestrings, and combine the results. This is a bit

Re: [Haskell-cafe] performance of map reduce

2008-09-19 Thread Bryan O'Sullivan
On Fri, Sep 19, 2008 at 2:31 PM, Manlio Perillo [EMAIL PROTECTED]wrote: By the way, this phrase: We allow multiple threads to read different chunks at once by supplying each one with a distinct file handle, all reading the same file here:

Re: [Haskell-cafe] Re: Python's big challenges, Haskell's big advantages?

2008-09-19 Thread Brandon S. Allbery KF8NH
On 2008 Sep 19, at 17:14, Manlio Perillo wrote: Brandon S. Allbery KF8NH ha scritto: There are two ways to handle a growable stack; both start with allocating each stack in a separate part of the address space with room to grow it downward. The simpler way uses stack probes on function

Re: [Haskell-cafe] performance of map reduce

2008-09-19 Thread Manlio Perillo
Bryan O'Sullivan ha scritto: On Fri, Sep 19, 2008 at 2:31 PM, Manlio Perillo [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: By the way, this phrase: We allow multiple threads to read different chunks at once by supplying each one with a distinct file handle, all reading the

[Haskell-cafe] Parsing arguments and reading configuration

2008-09-19 Thread Magnus Therning
Hi all, I'm looking for some inspiration for an elegant solution to a silly little problem I have. This might have a general well-known solution, or maybe there's something particularly elegant possible in Haskell. I just thought I'd ask. When writing a command line tool I want to use a

Re: [Haskell-cafe] ANNOUNCE: Extensible and Modular Generics for the Masses (EMGM) 0.1

2008-09-19 Thread Don Stewart
leather: Extensible and Modular Generics for the Masses == Extensible and Modular Generics for the Masses (EMGM) is a library for generic programming in Haskell using type classes. This is the initial release of a maintained

Re: [Haskell-cafe] Re: Library design question

2008-09-19 Thread Andre Nathan
On Fri, 2008-09-19 at 23:16 +0200, Daniel Fischer wrote: Yes. What's IO gotta do with it? I did it because of randomIO :( (or what about StateT (Graph a b) (State StdGen) ?). Now there's something I wouldn't have thought of... I changed the RandomGraph type to type RandomGraph a b = StateT

Re: [Haskell-cafe] Parsing arguments and reading configuration

2008-09-19 Thread Derek Elkins
On Fri, 2008-09-19 at 23:24 +0100, Magnus Therning wrote: Hi all, I'm looking for some inspiration for an elegant solution to a silly little problem I have. This might have a general well-known solution, or maybe there's something particularly elegant possible in Haskell. I just thought

Re: [Haskell-cafe] Parsing arguments and reading configuration

2008-09-19 Thread Antoine Latter
2008/9/19 Magnus Therning [EMAIL PROTECTED]: First I thought I'd treat the configuration in a similar way, but then I noticed a slight ordering problem. The command line arguments should take priority over the contents of the configuration file, but the location of the configuration can be

Re: [Haskell-cafe] Parsing arguments and reading configuration

2008-09-19 Thread Antoine Latter
On Fri, Sep 19, 2008 at 7:35 PM, Antoine Latter [EMAIL PROTECTED] wrote: I'm not sure how well it would hold up under maintenance, but you coud have a config sum-type which is itself a monoid, and then create two of them: And by sum-type I mean product type. Sheesh. Although having your

[Haskell-cafe] Ropes

2008-09-19 Thread Rafael Gustavo da Cunha Pereira Pinto
Hi all, Is there any implementation of the rope data structure in Haskell? I couldn't find any on Hackage, and I am intending to implement it. Regards, Rafael Gustavo da Cunha Pereira Pinto Electronic Engineer, MSc. ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] ANNOUNCE: citeproc-hs, a Haskell implementation of the Citation Style Language designed for Pandoc

2008-09-19 Thread Gwern Branwen
On Sat, Sep 13, 2008 at 1:33 PM, Andrea Rossato [EMAIL PROTECTED] wrote: Hello, I'm happy to announce the first release of citeproc-hs, a Haskell implementation of the Citation Style Language. citeproc-hs adds to Pandoc, the famous Haskell text processing tool, a Bibtex like citation and

Re: [Haskell-cafe] Re: XML (HXML) parsing :: GHC 6.8.3 space leak from 2000

2008-09-19 Thread Lev Walkin
Lev Walkin wrote: Simon Marlow wrote: Lev Walkin wrote: I wondered why would a contemporary GHC 6.8.3 exhibit such a leak? After all, the technique was known in 2000 (and afir by Wadler in '87) and one would assume Joe English's reference to most other Haskell systems ought to mean GHC.

Re: [Haskell-cafe] Ropes

2008-09-19 Thread Ryan Ingram
I think Data.Sequence uses fingertrees which are pretty fast. I used a handgrown rope-like structure for ICFPC07 but I wish I had known about Sequence; it would have likely just been better. -- ryan 2008/9/19 Rafael Gustavo da Cunha Pereira Pinto [EMAIL PROTECTED]: Hi all, Is there any

Re: [Haskell-cafe] Ropes

2008-09-19 Thread Don Stewart
RafaelGCPP.Linux: Hi all, Is there any implementation of the rope data structure in Haskell? I couldn't find any on Hackage, and I am intending to implement it. There's no mature rope implementation. Can you write a bytestring-rope that outperforms lazy bytestrings please :)