[Haskell-cafe] Lock-Free Data Structures using STMs in Haskell

2008-04-09 Thread Pete Kazmier
I recently read the STM paper on lock-free data structures [1] which I found very informative in my quest to learn how to use STM. However, there are a few things I do not fully understand and was hoping someone might be able to explain further. In the STM version of the ArrayBlockingQueue, the

[Haskell-cafe] Re: Lock-Free Data Structures using STMs in Haskell

2008-04-09 Thread Pete Kazmier
Bryan O'Sullivan [EMAIL PROTECTED] writes: Pete Kazmier wrote: data ArrayBlockingQueueSTM e = ArrayBlockingQueueSTM { [...] sa :: Array Int (TVar e) } It's unclear to me why the Array's elements must be wrapped in TVars. To allow them to be modified. You can't otherwise

[Haskell-cafe] Re: Yaham - Yet Another HAskell Mode for GNU Emacs

2007-06-17 Thread Pete Kazmier
Ian Zimmerman [EMAIL PROTECTED] writes: It has a different focus than the Moss haskell-mode that's normally used nowadays. Yaham strives, first and foremost, to integrate well with the rest of Emacs and respect the Emacs ecosystem. Could you elaborate on this? Perhaps an itemized list of

[Haskell-cafe] Re: Sneaking haskell in the workplace -- cleaning csv files

2007-06-17 Thread Pete Kazmier
Brandon S. Allbery KF8NH [EMAIL PROTECTED] writes: On Jun 15, 2007, at 18:37 , Jason Dagit wrote: I love to see people using Haskell, especially professionally, but I have to wonder if the real tool for this job is sed? :-) Actually, while sed could do that, it'd be a nightmare. You really

[Haskell-cafe] Re: Network.HTTP+ByteStrings Interface--Or: How to shepherd handles and go with the flow at the same time?

2007-05-25 Thread Pete Kazmier
As a newbie to Haskell, I found your thorough analysis very interesting. Thanks for the great read! I have a few questions regarding some of your comments, see below: Jules Bean [EMAIL PROTECTED] writes: E,F. Progressive GET pSynGET :: URL - ((Bool,ByteString) - IO ()) - IO ()

[Haskell-cafe] Stack overflow with my Trie implementation

2007-04-26 Thread Pete Kazmier
I've modified my Norvig spelling corrector to use a trie instead of Data.Map in the hopes of improving performance. Plus, this is fun and a great learning exercise for me. Unfortunately, when I load my trie with a large amount of data, I get a stack overflow. It's unclear to me why this is

[Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-22 Thread Pete Kazmier
Ketil Malde [EMAIL PROTECTED] writes: On Sun, 2007-04-22 at 00:25 -0400, Pete Kazmier wrote: Pete Kazmier [EMAIL PROTECTED] writes: I'd love to see other Haskell implementations as well if anyone has a few moments to spare. Admittedly, it took me several hours to get my version working

[Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-22 Thread Pete Kazmier
Bryan O'Sullivan [EMAIL PROTECTED] writes: After this switch, I found that spellchecking one word still took 4x as long in Haskell as Norvig's Python program. Since I was checking only one word in each case, essentially all of the runtime was taken up by building the word frequency map.

[Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-22 Thread Pete Kazmier
Derek Elkins [EMAIL PROTECTED] writes: After reading Bryan's post, I switched my right fold to a strict left fold and almost tripled my original speed. Could someone provide some guidelines on when to use each? I thought foldr should be used when building some large data structure such as

[Haskell-cafe] Haskell version of Norvig's Python Spelling Corrector

2007-04-21 Thread Pete Kazmier
Recently I read an interesting article by Peter Norvig[1] on how to write a spelling corrector in 21-lines of Python. I wanted to try and implement it in Haskell. My implementation is terribly slow and I was hoping for some tips on how to improve it and make it idiomatic. I'd love to see other

[Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

2007-04-21 Thread Pete Kazmier
Pete Kazmier [EMAIL PROTECTED] writes: I'd love to see other Haskell implementations as well if anyone has a few moments to spare. Admittedly, it took me several hours to get my version working, but I'm a Haskell newbie. Unfortunately, I think it runs as slow as it took me to write

[Haskell-cafe] Re: Tutorial on Haskell

2007-04-16 Thread Pete Kazmier
Simon Peyton-Jones [EMAIL PROTECTED] writes: My guess is that they'll be Linux/Perl/Ruby types, and they'll be practitioners rather than pointy-headed academics. Suggest concrete examples of programs that are * small * useful *

[Haskell-cafe] Re: Tutorial on Haskell

2007-04-16 Thread Pete Kazmier
Evan Laforge [EMAIL PROTECTED] writes: It illustrates a few nice things about haskell: laziness for the recursive defs and easy backtracking, low syntax overhead and custom operators for DSLs, composability, etc. Although that is true, I somehow feel that showing a perl, ruby, or python

[Haskell-cafe] Re: flip fix and iterate

2007-03-21 Thread Pete Kazmier
Claus Reinke [EMAIL PROTECTED] writes: I won't try to understand fix just yet, but I'm still confused by the type of fix: fix :: (a - a) - a It appears to me that it takes a function as an argument, and that function takes a single argument. So how are you passing fix an anonymous

[Haskell-cafe] Re: flip fix and iterate

2007-03-20 Thread Pete Kazmier
Matthew Brecknell [EMAIL PROTECTED] writes: Pete Kazmier: I understand the intent of this code, but I am having a hard time understanding the implementation, specifically the combination of 'fix', 'flip', and 'interate'. I looked up 'fix' and I'm unsure how one can call 'flip' on a function

[Haskell-cafe] Re: fix

2007-03-20 Thread Pete Kazmier
Matthew Brecknell [EMAIL PROTECTED] writes: As others have pointed out, fix is polymorphic, so a can stand for any type, including (b - c). Removing redundant parentheses, this means fix can directly specialise to: fix :: ((b - c) - b - c) - b - c I understand now. I think part of my

[Haskell-cafe] Re: Lazy IO and closing of file handles

2007-03-19 Thread Pete Kazmier
Matthew Brecknell [EMAIL PROTECTED] writes: Pete Kazmier: I attempted to read Oleg's fold-stream implementation [1] as this sounds quite appealing to me, but I was completely overwhelmed, especially with all of the various type signatures used. It would be great if one of the regular

[Haskell-cafe] Re: Lazy IO and closing of file handles

2007-03-19 Thread Pete Kazmier
Pete Kazmier [EMAIL PROTECTED] writes: I attempted to read Oleg's fold-stream implementation [1] as this sounds quite appealing to me, but I was completely overwhelmed, especially with all of the various type signatures used. It would be great if one of the regular Haskell bloggers (Tom

[Haskell-cafe] Re: Lazy IO and closing of file handles

2007-03-17 Thread Pete Kazmier
Matthew Brecknell [EMAIL PROTECTED] writes: So here's a test. I don't have any big maildirs handy, so this is based on the simple exercise of printing the first line of each of a large number of files. First, the preamble. import Control.Exception (bracket) import System.Environment import

[Haskell-cafe] Lazy IO and closing of file handles

2007-03-14 Thread Pete Kazmier
When using readFile to process a large number of files, I am exceeding the resource limits for the maximum number of open file descriptors on my system. How can I enhance my program to deal with this situation without making significant changes? My program takes one or more directories that

[Haskell-cafe] Re: Lazy IO and closing of file handles

2007-03-14 Thread Pete Kazmier
[EMAIL PROTECTED] (Donald Bruce Stewart) writes: pete-expires-20070513: When using readFile to process a large number of files, I am exceeding the resource limits for the maximum number of open file descriptors on my system. How can I enhance my program to deal with this situation without

[Haskell-cafe] How would you replace a field in a CSV file?

2006-10-01 Thread Pete Kazmier
The other day at work an opportunity arose where I was hoping to sneak some Haskell into the pipeline of tools used to process call detail records (CDRs). In the telecommunications industry, CDRs are used for billing. Each CDR is a single line record of 30 comma-separated values. Each line is

[Haskell-cafe] Re: How would you replace a field in a CSV file?

2006-10-01 Thread Pete Kazmier
[EMAIL PROTECTED] writes: For such a small self-contained task, I don't think Haskell is any better than Python. I figured as much, but I thought with the new FPS lazy bytestrings it might have a chance in terms of raw speed. On the other side of the coin, in terms of elegance, I thought I'd

[Haskell-cafe] Re: Editors for Haskell

2006-06-07 Thread Pete Kazmier
Simon Peyton-Jones [EMAIL PROTECTED] writes: You probably know this, but your kind of application is a big reason that we now make GHC available as a library. (Just say 'import GHC'.) You shouldn't need to parse Haskell yourself: just call GHC's parser. You get back a syntax tree with

[Haskell-cafe] Re: Editors for Haskell

2006-06-07 Thread Pete Kazmier
Pete Kazmier [EMAIL PROTECTED] writes: As part of my learning experience, I think I want to see if I can write a haskell pastebin that does proper syntax highlighting. Someone in #haskell suggested that I use just a lexer because using a parser is overkill. However, I can't make