[Haskell] threading mutable state through callbacks

2004-10-07 Thread Jules Bean
Hi, I've been playing with some haskell bindings which basically bind C procedures in the IO monad. To write 'interesting' programs, you often need to manage your own state in addition to the implicit IO state. I have been allocating references with newIORef and then passing them around all my

[Haskell] Lazy evaluation

2004-10-07 Thread Amadeo Casas Cuadrado
Hello, Could anyone tell me where can i find a webpage or a paper about how lazy implementation is done is Haskell? Thanks a lot! --Ama ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell

[Haskell] Re: threading mutable state through callbacks

2004-10-07 Thread oleg
Jules Bean wrote: Unfortunately, it's not going to work. It's not going to work because some of the procedures take callbacks, and the callbacks are values of type IO (). I can see two solutions to this: a) revert to using an IORef, and use lexical scoping to define my callbacks in a

Re: [Haskell] Lazy evaluation

2004-10-07 Thread Jules Bean
On 7 Oct 2004, at 22:14, Amadeo Casas Cuadrado wrote: Hello, Could anyone tell me where can i find a webpage or a paper about how lazy implementation is done is Haskell? For much more than you could ever want to know about haskell, look in Simon Peyton Jones's page:

Re: [Haskell-cafe] Integrating Haskell into a J2EE environment

2004-10-07 Thread Bjorn Lisper
I'm surprised that nobody has yet mentioned the ICFP2000 paper Composing Contracts: An Adventure in Financial Engineering by SPJ, Jean-Marc Eber, and Julian Seward. It seems to me that it could provide quite relevant reading. Björn Lisper Paul Hudak: I wouldn't write off Haskell so quickly.

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread Keith Wansbrough
I feel a bit guilty for my ugly wc implementation. At the moment of writing the first version I was thinking only about efficiency, not about elegance. [..] We have already created on this list a version which is fast and quite elegant at the same time, and I feel this one is better for the

Re: [Haskell-cafe] Can I determin the function name passed in?

2004-10-07 Thread Keith Wansbrough
I'm an utter noob to Haskell, and FP in gnereal. I would like to create a function taking an argument which is a function (actually an equation taking no args, but dependent on other equations), which prints the name of the function and and it's result. Is there a way of doing this in

Re: [Haskell-cafe] Can I determin the function name passed in?

2004-10-07 Thread Ketil Malde
Keith Wansbrough [EMAIL PROTECTED] writes: Instead, you should pass around data items that contain both the function and its name - either just pairs, [...] or proper data types ...or both, using records: data NamedFunc a b = NamedFunc { nameOf :: String, apply :: (a-b) } f =

[Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread Peter Simons
Keith Wansbrough writes: Count me as a vote for the better-but-slightly-slower wc. How about the attached program? On my machine it faster than Tomasz's version, and I think it's still a fairly clean source code. Using some random large file for input, I got these results with time(1): real

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread Ketil Malde
Peter Simons [EMAIL PROTECTED] writes: Keith Wansbrough writes: Count me as a vote for the better-but-slightly-slower wc. How about the attached program? On my machine it faster than Tomasz's version, and I think it's still a fairly clean source code I guess it's possible to submit three

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread MR K P SCHUPKE
Well, the sootout itself is using GHC, as it lists both language and implementation. There is no entry for NHC or Hugs... So I would say if the GHC specific code is neat and fast put it in... If people hant to see a NHC then there should be a separate implentation of haskell (for example I can

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread MR K P SCHUPKE
Also, its nice to see GHC ahead of Java now in the standard results... Would be nice to beat OCaml Clean though ... Keean. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread MR K P SCHUPKE
looking at ghc's scores... this would seem to be the next candidate for a rework: -- $Id: reversefile.ghc.html,v 1.6 2004/10/03 00:44:58 bfulgham Exp $ -- http://www.bagley.org/~doug/shootout/ -- from Julian Assange main = interact $ unlines . reverse . lines Compare this with the gcc

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread Malcolm Wallace
MR K P SCHUPKE [EMAIL PROTECTED] writes: Well, the sootout itself is using GHC, as it lists both language and implementation. There is no entry for NHC or Hugs... Both nhc98 and Hugs have been added in the last few days. Regards, Malcolm ___

Re: [Haskell-cafe] Can I determin the function name passed in?

2004-10-07 Thread Vincenzo Ciancia
On Thursday 07 October 2004 12:20, Keith Wansbrough wrote: You can't do this in Haskell.  In Haskell, functions are very lightweight things, and often they are inlined or compiled away in some way leaving no trace at runtime.  So there's nothing to reflect on.  This is in contrast to a

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootoutresults

2004-10-07 Thread Robert
Here is a quick fix for the Random Numbers category. Looks like a classic space-leak, again on the arithmetic operations. Speeds up results for me about 6X and brings memory usage down out of the stratosphere. w/o strictness: ~/shootout$ time random 90 +RTS -K3200 75.544410151 real

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread Ronny Wichers Schreur
Andre Pang writes (in the Haskell cafe): The executive summary of my thoughts is that it seems to be entirely possible to optimise Haskell to be competitive with other, more performance-focused languages, but it's hard... and from his blog: if you need speed, you can get it in Clean much more

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread MR K P SCHUPKE
I though clean was always strict, and that was the major difference between clean and haskell (that and the fact clean is a proprietry language) Keean. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread Andrew Butterfield
At 03:08 PM 07/10/2004 +0100, MR K P SCHUPKE wrote: I though clean was always strict, and that was the major difference between clean and haskell (that and the fact clean is a proprietry language) No - Clean is pure and lazy like Haskell, - the key difference is that it uses uniqueness types

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread Josef Svenningsson
Andre, I very much enjoyed reading your blog entry. I would like to make a few comments. First of all I heartly agree with what you call the main problem. I quote: The main problem I see with all this is that its just too hard for an average Haskell programmer to get good performance out of

RE: [Haskell-cafe] What Functions are Standard?

2004-10-07 Thread Simon Peyton-Jones
John | I have been writing code using the docs over at | http://www.haskell.org/ghc/docs/latest/html/libraries/index.html, which | is the only comprehensive library reference I could find. | | I am using some code from System.IO, supposedly from base. When I try | to build this with nhc98,

[Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread Peter Simons
Josef Svenningsson writes: What *is* true is that it is difficult to write good performance I/O in any of the *implementations* that we have. GHC has everything you need to do fast I/O in Haskell. If you use hGetBufNonBlocking with 'Ptr a', you have essentially the performance of read(2).

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread Ronny Wichers Schreur
MR K P SCHUPKE wrote: I though clean was always strict, and that was the major difference between clean and haskell (that and the fact clean is a proprietry language) Wrong on both accounts. See http://www.cs.ru.nl/~clean/About_Clean/about_clean.html and

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread Adrian Hey
On Thursday 07 Oct 2004 3:29 pm, Andrew Butterfield wrote: At 03:08 PM 07/10/2004 +0100, MR K P SCHUPKE wrote: I though clean was always strict, and that was the major difference between clean and haskell (that and the fact clean is a proprietry language) No - Clean is pure and lazy like

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread MR K P SCHUPKE
what about, quote: N.B. CleanLanguage is only available under a restrictive license. It's LGPL so long as you're not selling anything you write. Otherwise you have to purchase a commercial license. This probably means CleanLanguage will not survive long. Keean.

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout

2004-10-07 Thread MR K P SCHUPKE
results Okay... read the license, seems whoever wrote that article on Clean didn't read the license... You can use it under LGPL, for commercial purposes... Still cant help thinking its yet-another-lazy-functional language - I thought the whole point of Haskell was to stop prolifertion

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread Ketil Malde
Peter Simons [EMAIL PROTECTED] writes: The problem is not Haskell, nor is it the implementation. The problem is that beginners, including yours truly, tend to write awfully inefficient code once you give them a String and tell them: Here, that's the contents of your file. And it's just so

Re: [Haskell-cafe] Re: OCaml list sees abysmal Language Shootout results

2004-10-07 Thread MR K P SCHUPKE
I thought that you could use chained buffers to implement the lazy lists, that way the top level interface would still be simple. Also there should be an easy graph-rewrite operation that turns your 3 sequential operations (in the wc example) into 3 parallel ones... put these two together in

[Haskell-cafe] more shootout madness -- hashes in GHC

2004-10-07 Thread Robert
I've been playing around with the Hashes, Part II code from the shootout. I wanted to try to implement this test using Data.HashTable instead of Data.FiniteMap to see if that would buy us anything. In fact, the HashTable implementation is consistantly faster than FiniteMap, but not by a lot

[Haskell-cafe] IPv6?

2004-10-07 Thread John Goerzen
Hi, Network.Socket in GHC6 seems to be restricted to IPv4, despite the prsence of AF_INET6. How do I support IPv6 in Haskell? ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Being Compatible

2004-10-07 Thread John Goerzen
Hi, I have appreciated some of the comments here about what exactly is standardized. My next question is how to work at the greatest number of places. I am working on a library of Haskell-related utilities. There is some code in there that works with binary I/O, and some code that works with

[Haskell-cafe] The State Monad

2004-10-07 Thread John Goerzen
This thing is giving me fits. I need a global variable of sorts for an implementation of Syslog. (Yes, I really do.) It seems the right way to do that is the state monad. But I can't figure out how to do two simple things: * Read what is in there without modifying it * Modify it

Re: [Haskell-cafe] The State Monad

2004-10-07 Thread J. Garrett Morris
--- John Goerzen wrote: tick :: Int - State Int Int tick newval = do put newval return newval Or this: tick :: State Int Int tick = do n - get return n That is even more incomprehensible to me -- why would removing a line before the return cause a type error? --- end

[Haskell-cafe] Re: The State Monad

2004-10-07 Thread John Goerzen
On 2004-10-07, J. Garrett Morris [EMAIL PROTECTED] wrote: I can run both of those without a problem - could you post more of your code? It's probably somewhere else. /gXm You're right; I must have goofed somewhere. But I don't have real code yet, since I can't figure out the basic way of

[Haskell-cafe] Re: The State Monad

2004-10-07 Thread John Goerzen
On 2004-10-07, John Goerzen [EMAIL PROTECTED] wrote: This thing is giving me fits. I need a global variable of sorts for an implementation of Syslog. (Yes, I really do.) OK, my problem is that I have been looking at the world wrong. I found what I really needed in Data.IORef. Which leaves

Re: [Haskell-cafe] Re: The State Monad

2004-10-07 Thread Ben Lippmeier
John Goerzen wrote: Which leaves me with an odd curiosity -- I still can't figure out how state monads are anything but syntactic sugar (and lead more to spaghetti code at that g) Perhaps because state monads = syntactic sugar. The state monad is just a nice(er) way of passing around some global