Re: [Haskell-cafe] Code review: efficiency question

2006-05-03 Thread Brian Hulley
Bulat Ziganshin wrote: [ideas including reverseMapM_] you will laugh, but speed of your two solutions depends on so many factors (including size of CPU cache) that noone can say that is better in general. although for small lists reverseMapM_ should be faster than reverse+mapM. what will be

Re: [Haskell-cafe] Code review: efficiency question

2006-05-03 Thread Josef Svenningsson
Brian, You might also want to take a look at the list fusion functionality in GHC which often can help optimize your programs when programming with lists. http://www.haskell.org/ghc/docs/latest/html/users_guide/rewrite-rules.html#id3153234 It doesn't help in your particular program but it might

[Haskell-cafe] Re: Optimizing locking with MVars

2006-05-03 Thread Simon Marlow
This is interesting, thanks. I propose to add INLINE pragmas to withMVar and friends. Having an interface for simple locks sounds like a good idea to me. Would you like to send a patch? This won't affect Handle I/O unfortunately, because we need block to protect against asynchronous

RE: [Haskell-cafe] Is it possible to export module aliases?

2006-05-03 Thread Simon Peyton-Jones
Are you asking for the same thing as described under Permit qualified exports on this Haskell Prime page? http://haskell.galois.com/cgi-bin/haskell-prime/trac.cgi/wiki/ModuleSyst em Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of |

[Haskell-cafe] Re: Am I lazy enough?

2006-05-03 Thread Spencer Janssen
ByteString's are strict in their contents, so when you do an hGetContents you'll read the entire file into memory! This negates any laziness benefits right off the bat. The trickiest part is the lazy IO, you have to use unsafeInterleaveIO or something similar. Below is a program that does

[Haskell-cafe] NewBinary/ BinMem and IO monad

2006-05-03 Thread Marc Weber
I'm trying to write some true type library (implementing only the tables I need at the moment). When loading a font file it doesn't make sense to parse every table which isn't needed. So lazyness of haskell would perfectly meet requirements here. My problem: NewBinary supports memory buffers.

Re: [Haskell-cafe] Re: Optimizing locking with MVars

2006-05-03 Thread John Meacham
On Wed, May 03, 2006 at 12:07:19PM +0100, Simon Marlow wrote: This won't affect Handle I/O unfortunately, because we need block to protect against asynchronous exceptions. I'm still not certain you won't need that in the stream library, too: check any stateful code (eg. buffering) and

Re: [Haskell-cafe] NewBinary/ BinMem and IO monad

2006-05-03 Thread Bulat Ziganshin
Hello Marc, Thursday, May 4, 2006, 2:21:58 AM, you wrote: getTable1 bh = do bh = seek bh offset -- seek to the beginning of the table get binary data and build internal representation return list of glyph and outlines and ... just add unsafePerformIO: getTable1 bh = unsafePerformIO $

Re[2]: [Haskell-cafe] Re: Optimizing locking with MVars

2006-05-03 Thread Bulat Ziganshin
Hello John, Thursday, May 4, 2006, 12:33:54 AM, you wrote: This won't affect Handle I/O unfortunately, because we need block to protect against asynchronous exceptions. I'm still not certain you won't need that in the stream library, too: check any stateful code (eg. buffering) and