Re: [Haskell-cafe] Haskell performance (again)!

2006-10-09 Thread Brian Hulley
Lennart Augustsson wrote: I think your first try looks good. [snip] ... addPoly1 p1@(p1h@(Nom p1c p1d):p1t) p2@(p2h@(Nom p2c p2d):p2t) | p1d == p2d = Nom (p1c + p2c) p1d : addPoly1 p1t p2t | p1d < p2d = p1h : addPoly1 p1t p2 | p1d > p2d = p2h : addPoly1 p1 p2t ... The last comparison

Re: [Haskell-cafe] a monad for secret information

2006-10-09 Thread Cale Gibbard
On 09/10/06, Seth Gordon <[EMAIL PROTECTED]> wrote: I finally (think I) understand monads well enough to make one up: > module Secret (Secret, classify, declassify) > where > > data Secret a = Secret a > > classify :: a -> Secret a > classify x = Secret x > > declassify :: Secret a -> String ->

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

2006-10-09 Thread John Goerzen
On 2006-10-01, Pete Kazmier <[EMAIL PROTECTED]> wrote: > For those that know python, here is a very simple implementation that > happens to be very fast compared to my Haskell version and very short: > > for line in sys.stdin: > fields = line.split(',') Of course, this doesn't handle q

[Haskell-cafe] a monad for secret information

2006-10-09 Thread Seth Gordon
I finally (think I) understand monads well enough to make one up: module Secret (Secret, classify, declassify) where data Secret a = Secret a classify :: a -> Secret a classify x = Secret x declassify :: Secret a -> String -> Maybe a declassify (Secret x) "xyzzy" = Just x declassify (Secret x

[Haskell-cafe] Re: Strictness, order of IO operations: NewCGI & HDBC

2006-10-09 Thread John Goerzen
I forgot to add a couple of things. First, you mentioned the unknown exception. If you were to replace the "main =" line with "main = handleSqlError $ ", then you would find a more useful error message. That will cause HDBC to automatically transform any uncaught HDBC exception into a standard H

Re: [Haskell-cafe] Haskell performance (again)!

2006-10-09 Thread Lennart Augustsson
I think your first try looks good. The only thing to worry about would be the + being too lazy. But that's easy to fix at the same time as improving your code in another respect. It's usually good to use real types instead of synonyms, so let's do that. data Nom = Nom Int Int type PolyN

[Haskell-cafe] Re: Strictness, order of IO operations: NewCGI & HDBC

2006-10-09 Thread John Goerzen
On Mon, Oct 09, 2006 at 04:01:02PM -0600, Tim Smith wrote: > main = >do >dbh <- connectODBC "DSN=test" >res <- DB.getTables dbh >-- print (show ((concat . intersperse ", ") res)) >DB.disconnect dbh >print (show ((concat . intersperse ", ") res)) > > Am I just expecting the

[Haskell-cafe] Re: Strictness, order of IO operations: NewCGI & HDBC

2006-10-09 Thread Tim Smith
Hello, Haskell Cafe. I posted a question a while ago about this, but didn't receive any responses. I'd like to try again. I've got a test case which uses John Goerzen's HDBC.ODBC. The problem I have is that it appears too lazy - using the results of a query after disconnecting causes an "unkno

Re: [Haskell-cafe] Vertical tabs in source code and other obscure chars

2006-10-09 Thread Thomas Conway
Mostly hysterical raisins, I think. T. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] casting

2006-10-09 Thread Thomas Conway
Thanks Misha & Matthias. I now get what's going on. The mention of the word "dictionary" revealed it all. I've spent the last 7 years programming in C++, and had dynamic_cast<> firmly fixed in my head. I totally forgot that Fergus Henderson and I independently reinvented dictionary passing for th

Re: [Haskell-cafe] Re: Haskell performance (again)!

2006-10-09 Thread Cale Gibbard
On 09/10/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: Cale Gibbard wrote: > I might also like to point out that by "small" and "large", we're > actually referring to the number of ways in which components of the > datastructure can be computed separately, which tends to correspond > nicely to

[Haskell-cafe] Vertical tabs in source code and other obscure chars

2006-10-09 Thread Brian Hulley
Hi, In the Haskell98 report at http://haskell.org/onlinereport/lexemes.html section 2.2 has the rule: whitechar -> newline | vertab | space | tab | uniWhite Does anyone know what a vertical tab is supposed to do? Is there any reason to allow them as whitespace? (Does anyone in the universe

[Haskell-cafe] Re: Haskell performance (again)!

2006-10-09 Thread apfelmus
Yang wrote: >> > But laziness will cause this to occupy Theta(n)-space of cons-ing >> > thunks. >> >> No, it doesn't. Insisting on accumulator recursion does. Actually, >> using reverse does. Think about it, a strict reverse cannot use less >> than O(n) space, either. > > Well, in general, the

[Haskell-cafe] Re: Haskell performance (again)!

2006-10-09 Thread apfelmus
Cale Gibbard wrote: > On 08/10/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> large -> largedepends on large input like above >> but roughly same otherwise >> small -> largeroughly same > > Actually, it's an important point that laziness is generally > preferable in

Re: [Haskell-cafe] casting

2006-10-09 Thread Misha Aizatulin
Thomas Conway wrote: > I'm having some difficulty with typeclasses. > > What I'm trying to do should be obvious, but it's still giving me > trouble. I want to take a packaged item, and strengthen the > constraints on its type. Rather than being just any type that is an > instance of A, I want to d

[Haskell-cafe] Re: casting

2006-10-09 Thread Thomas Conway
On 10/9/06, I wrote: So, can anyone suggest how I can achieve my goal? And how many milliolegs of type hackery will it take? ;-) Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] casting

2006-10-09 Thread Thomas Conway
Hi All I'm having some difficulty with typeclasses. What I'm trying to do should be obvious, but it's still giving me trouble. I want to take a packaged item, and strengthen the constraints on its type. Rather than being just any type that is an instance of A, I want to do a runtime check and do

Re: [Haskell-cafe] Re: Haskell performance (again)!

2006-10-09 Thread Cale Gibbard
On 08/10/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: large -> largedepends on large input like above but roughly same otherwise small -> largeroughly same Actually, it's an important point that laziness is generally preferable in these cases as well, since the lar

Re: [Haskell-cafe] Announce: Monad Transformer Tutorial

2006-10-09 Thread Tomasz Zielonka
An errata for my email: On Mon, Oct 09, 2006 at 09:44:47AM +0200, Tomasz Zielonka wrote: > No let's get to nitpicking ;-) should be Now let's get to nitpicking ;-) > * page 8, at about 85%: you say "The state maintained in our example is > a simple integer value, but it *can* be any data typ

Re: [Haskell-cafe] Announce: Monad Transformer Tutorial

2006-10-09 Thread Eric Kow
I have not read this yet, but would you be willing to put this tutorial directly on the Haskell wiki? You lose the niceness of latex, but you gain collaborative editing (which is at least useful for suggestions like the ones Tomasz made) If you put it on the wiki, we might be interested in steali

Re: [Haskell-cafe] Announce: Monad Transformer Tutorial

2006-10-09 Thread Tomasz Zielonka
On Fri, Oct 06, 2006 at 11:40:46AM +0200, Martin Grabmueller wrote: > I hereby announce a small tutorial on using monad transformers. In contrast > to others found on the web, it concentrates on using them, not on their > implementation. > > I'd like to hear comments, suggestions, etc. about it!