Re: [Haskell-cafe] System.Exit

2007-07-05 Thread Stefan O'Rear
On Thu, Jul 05, 2007 at 02:04:32PM +1000, Thomas Conway wrote: Hi All, Can anyone tell me what System.Exit.exitWith is actually supposed to do? As far as I can tell, it seems to be a synonym of (return ()). Okay, I'll stop being provocative and try and be helpful. So I have a web server,

[Haskell-cafe] Lightweight sequent calculus and linear abstractions

2007-07-05 Thread oleg
Conor McBride has posed an interesting problem: implement constructors P v for embedding pure values v Ofor holes f :$ a for application, left-associative and an interpreting function emmental such that emmental (P (+) :$ (P (*) :$ O :$ P

Re: [Haskell-cafe] folds with escapes

2007-07-05 Thread oleg
Can you do dropWhile in terms of foldr? One can write foldr that represents drop or dropWhile of the original foldr. One can do even more: zip two folds. That is, obtain a fold that is equivalent to zipping up two lists represented by the original folds. Even furthermore, one can do all these

Re[2]: [Haskell-cafe] Deadlock in real number multiplication (Was: Where's the problem ?)

2007-07-05 Thread Miguel
R Another interesting thing I've discovered is: Prelude length [1..100] R 100 Prelude Data.List.genericLength [1..100] R *** Exception: stack overflow R Maybe there is something wrong with Integer ? No, there is something wrong with genericLength: Prelude Data.List.foldl (+) 0 $

Re: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Philip Armstrong
On Thu, Jul 05, 2007 at 08:50:42AM +1000, Donald Bruce Stewart wrote: [useful stuff] So, in fact pretty much everything I was looking for exists, in some form or other! It's just a bit hard to find at the moment, perhaps because none of this stuff is regarded as 'core Haskell' by any of the

Re: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Thomas Conway
I was explaining Haskell to a perl/python hacking friend recently and characterized things thus: Perl is a horrible language with fantastic libraries. Haskell is a fantastic language with horrible libraries. Actually, many of the libraries that exist for Haskell *are* fantastic, it's just that

Re: [Haskell-cafe] System.Exit

2007-07-05 Thread Tomasz Zielonka
On Wed, Jul 04, 2007 at 11:16:20PM -0700, Stefan O'Rear wrote: The documentation says: | Computation exitWith code throws ExitException code. Normally this | terminates the program, returning code to the program's caller. Before | the program terminates, any open or semi-closed handles are

[Haskell-cafe] Write a library today! Was: Binary serialization, was Re: Abstraction leakAKa

2007-07-05 Thread Donald Bruce Stewart
drtomc: I was explaining Haskell to a perl/python hacking friend recently and characterized things thus: Perl is a horrible language with fantastic libraries. Haskell is a fantastic language with horrible libraries. Actually, many of the libraries that exist for Haskell *are* fantastic,

Re: [Haskell-cafe] folds with escapes

2007-07-05 Thread Claus Reinke
Can you do dropWhile in terms of foldr? I don't see how. If you are really keen, you might want to try altering the working backwards with tuples version into one which is properly lazy (many people who read the paper pointed out the omission). you might want to mention the story of the

[Haskell-cafe] Re: Deadlock in real number multiplication (Was: Where's the problem ?)

2007-07-05 Thread apfelmus
Philip Armstrong wrote: genericLength :: (Num i) = [b] - i genericLength []= 0 genericLength (_:l) = 1 + genericLength l So genericLength is lazily building up unevaluated (+) expressions and running out of stack space. Is there a good reason for genericLength to

[Haskell-cafe] Re: Playing with delimited continuations

2007-07-05 Thread oleg
The ZFS library contains the most up-to-date implementation of the CC monad and the transformer. I have a few other versions scattered around, but they are probably not relevant. I found the CC_FrameT.hs to be the fastest one. Is that you can think of normal continuations as delimited

Re: [Haskell-cafe] A very nontrivial parser

2007-07-05 Thread Malcolm Wallace
Andrew Coppin [EMAIL PROTECTED] wrote: My goal is to be able to stack multiple parsers one on top of the other - but be able to *change* the stack half way through parsing if needed. Essentially, I have the stacked function, where if I do x - stacked foo parser1 bar parser2 y -

[Haskell-cafe] Re: Lightweight sequent calculus and linear abstractions

2007-07-05 Thread Conor McBride
Hi Oleg On 5 Jul 2007, at 07:15, [EMAIL PROTECTED] wrote: Conor McBride has posed an interesting problem: implement constructors P v for embedding pure values v Ofor holes f :$ a for application, left-associative and an interpreting function emmental

Re: [Haskell-cafe] System.Exit

2007-07-05 Thread Thomas Conway
FWIW, I implemented the STM based solution, and it works a treat. It's less of a hack than the version where I got the child thread to send a SIGINT. ;-) T. -- Dr Thomas Conway [EMAIL PROTECTED] Silence is the perfectest herald of joy: I were but little happy, if I could say how much.

Re: [Haskell-cafe] Parsers are monadic?

2007-07-05 Thread Claus Reinke
(b) i like my combinator grammars to be reversible, so that a single grammar specification can be used for both parsing and unparsing/pretty-printing. that means i have to define the details myself anyway. the latest such experiment is not necessarily the simplest variant, for

[Haskell-cafe] Re: Playing with delimited continuations

2007-07-05 Thread Dan Doel
On Thursday 05 July 2007, [EMAIL PROTECTED] wrote: I believe the answer to this question is NO. That means, (delimited) continuations expose the fundamental limitation of monadic transformers. I suppose this is a bit disheartening, but I suppose it's also good to know I wasn't totally off

[Haskell-cafe] Profiling and Threading: never the twain shall meet

2007-07-05 Thread Dougal Stanton
Hi Haskellers, It seems that profiling and threading are not supported at the same time in GHC6.6. At least, it objects to using both the flags at the same time, and there's a Trac entry for that issue. So I just wanted to be sure that I really need threading. I'm passing text through some

Re: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Jonathan Cast
On Thursday 05 July 2007, Thomas Conway wrote: I was explaining Haskell to a perl/python hacking friend recently and characterized things thus: Perl is a horrible language with fantastic libraries. Haskell is a fantastic language with horrible libraries. Actually, many of the libraries that

Re: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Paul Moore
On 05/07/07, Jonathan Cast [EMAIL PROTECTED] wrote: Can't say I agree. I've been learning Python, and have been very un-impressed so far with its library coverage, which I would rate no better than (in terms of the POSIX bindings, worse than) Haskell. It probably depends on your perspective.

Re[2]: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Bulat Ziganshin
Hello Paul, Thursday, July 5, 2007, 7:00:46 PM, you wrote: * Gzip compress a data stream zlib * Send an email * Parse an ini file The one thing off the top of my head that Python had was Base64, but that's 20 MissingH * Calculate the MD5 checksum of a file crypto -- Best regards,

Re: Re[2]: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Paul Moore
On 05/07/07, Bulat Ziganshin [EMAIL PROTECTED] wrote: * Gzip compress a data stream zlib * Send an email * Parse an ini file The one thing off the top of my head that Python had was Base64, but that's MissingH * Calculate the MD5 checksum of a file crypto Thanks. The need I had for

Re: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Philip Armstrong
On Thu, Jul 05, 2007 at 09:41:23AM -0700, Dave Bayer wrote: There are people who claim with a straight face that they migrated to OS X primarily to use TextMate http://www.textmate.com Presumably you mean http://macromates.com/ ? Phil -- http://www.kantaka.co.uk/ .oOo. public key:

Re: Re[2]: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Neil Mitchell
Hi It's not a great experience now, but hopefully things are moving in the right direction. - Found crypto 3.0.3 on hackage. - Tried to build, it depends on NewBinary Cabal-install is intended to remove this problem, so that you can say i want crypto and it gets everything that requires. -

Re: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Dave Bayer
On Jul 5, 2007, at 8:00 AM, Paul Moore wrote: It probably depends on your perspective. I've found lots of tasks that would be a simple library call in Python, but which require me to write the code myself in Haskell. Examples: * Calculate the MD5 checksum of a file How's this, only one line

Re: Re[2]: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Paul Moore
On 05/07/07, Paul Moore [EMAIL PROTECTED] wrote: The need I had for these is no longer current, but sometime I'll try an experiment and see how easy it is, on a relatively clean Windows box with just GHC installed, to grab and use these libraries. Just for fun I had a go with crypto: - Found

Re: Re[2]: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Duncan Coutts
On Thu, 2007-07-05 at 17:07 +0100, Paul Moore wrote: On 05/07/07, Bulat Ziganshin [EMAIL PROTECTED] wrote: * Gzip compress a data stream zlib * Send an email * Parse an ini file The one thing off the top of my head that Python had was Base64, but that's MissingH *

Re[4]: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Bulat Ziganshin
Hello Paul, Thursday, July 5, 2007, 8:07:34 PM, you wrote: note: with Python, I'm used to 3rd party modules being available as Windows installer packages - does the concept of an installable binary for something like MissingH, which I can just install and use, make sense for a compiled

Re: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Paul Moore
On 05/07/07, Dave Bayer [EMAIL PROTECTED] wrote: How's this, only one line is specific to your problem: [...] md5 - doShell md5 -q md5.hs Doesn't work on my (Windows) PC, where I have no md5 command available. While I agree in theory with the idea of combining focused tools, it's a

Re: Re[2]: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Paul Moore
On 05/07/07, Neil Mitchell [EMAIL PROTECTED] wrote: - But no simple examples, and the haddoc docs show APIs, but not usage examples! Complain to the author. Yes, that's completely unrelated to library availability issues. I got off the topic, in all my ranting. Sorry. Part of the problem

Re: Re[2]: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Duncan Coutts
On Thu, 2007-07-05 at 17:39 +0100, Paul Moore wrote: I see you've already responded, and we're in broad agreement. So I won't labour the point. It's an infrastructure issue rather than a technical one, and it *will* improve. What will be interesting is how much the generally lousy Windows

Re: [Haskell-cafe] A very nontrivial parser

2007-07-05 Thread Andrew Coppin
Malcolm Wallace wrote: I can't help thinking that all you really want to do is parse the same data twice, through an intermediate representation. That only requires you to feed the result of one parse into a top-level call to a different parser. For instance: this = do tmp - parser1

Re: [Haskell-cafe] A very nontrivial parser

2007-07-05 Thread Andrew Coppin
Jonathan Cast wrote: On Wednesday 04 July 2007, Andrew Coppin wrote: Anybody have a solution to this? newtype Parser state x y = Parser (forall src. Source src = (state, src x) - (state, src x, y)) ...OK, anybody have a solution that works in Haskell 98? Definition of monad

Re: Re[2]: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Ian Lynagh
On Thu, Jul 05, 2007 at 06:08:45PM +0100, Duncan Coutts wrote: On Thu, 2007-07-05 at 17:51 +0100, Neil Mitchell wrote: - Found that on hackage, downloaded and built OK. Lots of scary warnings about happy, greencard etc, not being found during configure, but let's go on. I've

Re: [Haskell-cafe] Re: Lightweight sequent calculus and linear abstractions

2007-07-05 Thread Conor McBride
On 5 Jul 2007, at 18:35, Chung-chieh Shan wrote: [EMAIL PROTECTED] wrote in article [EMAIL PROTECTED] in gmane.comp.lang.haskell.cafe: Conor McBride has posed an interesting problem: implement constructors P v for embedding pure values v Ofor holes f :$ a

[Haskell-cafe] Re: Lightweight sequent calculus and linear abstractions

2007-07-05 Thread Chung-chieh Shan
[EMAIL PROTECTED] wrote in article [EMAIL PROTECTED] in gmane.comp.lang.haskell.cafe: Conor McBride has posed an interesting problem: implement constructors P v for embedding pure values v Ofor holes f :$ a for application, left-associative and an

Re: [Haskell-cafe] Profiling and Threading: never the twain shall meet

2007-07-05 Thread Albert Y. C. Lai
Dougal Stanton wrote: do (hin, hout, herr, ph) - runInteractiveProcess cmd args Nothing Nothing forkIO $ hPutStr hin content hClose hin out - hGetContents hout return (ph, out) which seems to require threading. If I compile without, it will hang indefinitely, I presume deadlocked. Is

Re: [Haskell-cafe] A very nontrivial parser

2007-07-05 Thread Jonathan Cast
On Thursday 05 July 2007, Andrew Coppin wrote: Jonathan Cast wrote: On Wednesday 04 July 2007, Andrew Coppin wrote: Anybody have a solution to this? newtype Parser state x y = Parser (forall src. Source src = (state, src x) - (state, src x, y)) ...OK, anybody have a solution that

Re: [Haskell-cafe] A very nontrivial parser

2007-07-05 Thread Jonathan Cast
Andrew: By the way, could you share your definition of Stack with us? It isn't at all clear to me how stacked actually decides to terminate the underlying parser. Jonathan Cast http://sourceforge.net/projects/fid-core http://sourceforge.net/projects/fid-emacs

Re: [Haskell-cafe] A very nontrivial parser

2007-07-05 Thread Andrew Coppin
Jonathan Cast wrote: On Thursday 05 July 2007, Andrew Coppin wrote: ...OK, anybody have a solution that works in Haskell 98? Rank-2 types are perhaps /the/ most common, widely accepted extension to Haskell 98, after the approved addendum for FFI and the draft addendum for

Re: [Haskell-cafe] A very nontrivial parser

2007-07-05 Thread Andrew Coppin
Jonathan Cast wrote: Andrew: By the way, could you share your definition of Stack with us? It isn't at all clear to me how stacked actually decides to terminate the underlying parser. Yeah, I'll post the complete source here in a little while. I think that's probably the only way

Re: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Dave Bayer
On Jul 5, 2007, at 9:52 AM, Paul Moore wrote: You're changing the problem from finding a Haskell library (which only needs to be installed on the development machine at compile time) to finding a 3rd party utility, which has to be installed at runtime ... Not a good trade-off. The

Re[2]: [Haskell-cafe] A very nontrivial parser

2007-07-05 Thread Miguel Mitrofanov
AC For the Nth time... The amount of data processed by parser1 needs AC to depend on the amount of data processed by parser2. (The amount AC of data output by each parser is very nontrivially related to the AC amount of data consumed.) What about lazyness? Let parser1 process ALL the data and

[Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Dominic Steinitz
(Bonus points for being able to parse ASN.1 and generate appropriate Haskell datatypes serialization primitives automatically :-) ) I think there's at least an ASN.1 definition in the crypto library. Dominic might be able to enlighten us on that. No bonus points I'm afraid. There is an

Re: [Haskell-cafe] A very nontrivial parser [Source code]

2007-07-05 Thread Andrew Coppin
-- This is probably line-wrapped horribly... module Process ( Source (..), PState (), start, Process (run), get_state, set_state, alt_state, get, eof, pure, count, many, stack ) where class Source src where empty :: src x - Bool fetch :: src x -

Re: [Haskell-cafe] A very nontrivial parser

2007-07-05 Thread Jonathan Cast
On Thursday 05 July 2007, Andrew Coppin wrote: Jonathan Cast wrote: On Thursday 05 July 2007, Andrew Coppin wrote: ...OK, anybody have a solution that works in Haskell 98? Rank-2 types are perhaps /the/ most common, widely accepted extension to Haskell 98, after the approved addendum

Re: [Haskell-cafe] Sparse documentation

2007-07-05 Thread Ian Lynagh
Hi Andrew, On Wed, Jul 04, 2007 at 07:26:48PM +0100, Andrew Coppin wrote: Writing documentation for libraries is one way in which ordinary Haskell users can really contribute to the Haskell community. It’s not hard to do (grab the Darcs repo, type away), and it’s widely appreciated.

Re: [Haskell-cafe] A very nontrivial parser [Source code]

2007-07-05 Thread Jonathan Cast
On Thursday 05 July 2007, Andrew Coppin wrote: snip This version works (I think). Also, using this syntax may make the distinction between existential constructors and rank-2 constructors a little clearer. *AlgoRLE run decodeRLEb1 $ start () $ encodeRLEb [1, 2, 3] ([1],PState {state = (),

[Haskell-cafe] interrupting an accept()ing thread

2007-07-05 Thread Lukas Mai
Hello, cafe! I have the following code (paraphrased): ... forkIO spin ... spin = do (t, _) - accept s -- (*) forkIO $ dealWith t -- (**) spin My problem is that I want to stop spin from another thread. The obvious solution would be to throw it an exception. However, that leaks a

Re: [Haskell-cafe] Binary serialization, was Re: Abstraction leak

2007-07-05 Thread Donald Bruce Stewart
p.f.moore: On 05/07/07, Jonathan Cast [EMAIL PROTECTED] wrote: Can't say I agree. I've been learning Python, and have been very un-impressed so far with its library coverage, which I would rate no better than (in terms of the POSIX bindings, worse than) Haskell. It probably depends on

[Haskell-cafe] reimplementing break (incorrectly) quickcheck p list gives me feedback that it breaks on list, but not what predicate test caused the breakage

2007-07-05 Thread Thomas Hartman
I am a total quickcheck noob. Is there a way to find out what predicate test function is, below? Also, is there a way I can ask quickcheck to test lists of various built in types, not just Int? *** Falsifiable, after 4 tests: function [1] *Recursion testMyBreak Falsifiable, after 1

Re: [Haskell-cafe] interrupting an accept()ing thread

2007-07-05 Thread Donald Bruce Stewart
drtomc: On 7/6/07, Lukas Mai [EMAIL PROTECTED] wrote: Hello, cafe! Have you been reading my mind? See the other recent Cafe thread (um, titled something about System.Exit). Here's my solution: ... If you've got small examples illustrating how to use the various concurrency abstractions,

[Haskell-cafe] Re: folds with escapes

2007-07-05 Thread Logan Capaldo
Michael Vanier mvanier at cs.caltech.edu writes: I'm sure this has been done a hundred times before, but a simple generalization of foldl just occurred to me and I wonder if there's anything like it in the standard libraries (I couldn't find anything). Basically, I was trying to define

Re: [Haskell-cafe] interrupting an accept()ing thread

2007-07-05 Thread Thomas Conway
On 7/6/07, Lukas Mai [EMAIL PROTECTED] wrote: Hello, cafe! Have you been reading my mind? See the other recent Cafe thread (um, titled something about System.Exit). Here's my solution: acceptLoop sok reqChan = do req - Network.Socket.accept sok atomically (writeTChan reqChan req)

Re: [Haskell-cafe] A very nontrivial parser

2007-07-05 Thread Donald Bruce Stewart
andrewcoppin: Jonathan Cast wrote: On Thursday 05 July 2007, Andrew Coppin wrote: ...OK, anybody have a solution that works in Haskell 98? Rank-2 types are perhaps /the/ most common, widely accepted extension to Haskell 98, after the approved addendum for FFI and the draft

Re: [Haskell-cafe] A very nontrivial parser

2007-07-05 Thread Stefan O'Rear
On Fri, Jul 06, 2007 at 10:56:43AM +1000, Donald Bruce Stewart wrote: andrewcoppin: Jonathan Cast wrote: On Thursday 05 July 2007, Andrew Coppin wrote: ...OK, anybody have a solution that works in Haskell 98? Rank-2 types are perhaps /the/ most common, widely accepted

Re: [Haskell-cafe] interrupting an accept()ing thread

2007-07-05 Thread Lukas Mai
Am Freitag, 6. Juli 2007 02:13 schrieb Thomas Conway: Here's my solution: acceptLoop sok reqChan = do req - Network.Socket.accept sok atomically (writeTChan reqChan req) acceptLoop sok reqChan mainLoop reqChan quitVar liveOpCountVar = do action - atomically (quitNow

Re: [Haskell-cafe] interrupting an accept()ing thread

2007-07-05 Thread Thomas Conway
On 7/6/07, Lukas Mai [EMAIL PROTECTED] wrote: I don't see how this solves the problem. AFAICS acceptLoop never returns and sok is never closed. On the other hand, my program doesn't need a liveOpCount because the subthreads take care of themselves. It's just the accept loop I need to break