Re: mapM as a Space Leak (Was: [Haskell-cafe] about Haskell code written to be too smart)

2009-03-26 Thread Thomas Hartman
 I wonder if JHC
 or some other compiler might work better with these examples?

Are you saying that different compilers might give different answers?

Yikes!

Too clever indeed!

2009/3/26  rocon...@theorem.ca:
 On Wed, 25 Mar 2009, Thomas Hartman wrote:

 With the state version, there's a lot of behind-the-scenes magic, and
 as we've seen, things can go wrong.

 Also, the issue isn't infinite lists, but lists that are longer than
 the sum of the partitions provided. The state monad partition version
 goes equally as badly awry if the test is restructured as

 testP pf = mapM_ putStrLn  [
         show . pf ( take 1000 [3,7..] ) $ [1..10]
         , show . pf [3,7,11,15] $ ( take (10^6) [1..])
         , show . head . last $ pf (take 1000 $ [3,3..]) [1..10^6]
       ]

 This is interesting.  It seems to be the familiar issue that sequence does
 not play as nicely with the GC as one might imagine:
 http://www.reddit.com/r/haskell/comments/7itbi/mapm_mapm_and_monadic_statements/c06rwnb?context=1

 I suspect this may be a general problem that we will keep encountering when
 using higher-order functions, at least with this compiler.  I wonder if JHC
 or some other compiler might work better with these examples?

 --
 Russell O'Connor                                      http://r6.ca/
 ``All talk about `theft,''' the general counsel of the American Graphophone
 Company wrote, ``is the merest claptrap, for there exists no property in
 ideas musical, literary or artistic, except as defined by statute.''
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


mapM as a Space Leak (Was: [Haskell-cafe] about Haskell code written to be too smart)

2009-03-26 Thread roconnor

On Wed, 25 Mar 2009, Thomas Hartman wrote:


With the state version, there's a lot of behind-the-scenes magic, and
as we've seen, things can go wrong.

Also, the issue isn't infinite lists, but lists that are longer than
the sum of the partitions provided. The state monad partition version
goes equally as badly awry if the test is restructured as

testP pf = mapM_ putStrLn  [
 show . pf ( take 1000 [3,7..] ) $ [1..10]
 , show . pf [3,7,11,15] $ ( take (10^6) [1..])
 , show . head . last $ pf (take 1000 $ [3,3..]) [1..10^6]
   ]


This is interesting.  It seems to be the familiar issue that sequence does 
not play as nicely with the GC as one might imagine:

http://www.reddit.com/r/haskell/comments/7itbi/mapm_mapm_and_monadic_statements/c06rwnb?context=1

I suspect this may be a general problem that we will keep encountering 
when using higher-order functions, at least with this compiler.  I wonder 
if JHC or some other compiler might work better with these examples?


--
Russell O'Connor  http://r6.ca/
``All talk about `theft,''' the general counsel of the American Graphophone
Company wrote, ``is the merest claptrap, for there exists no property in
ideas musical, literary or artistic, except as defined by statute.''
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: mapM as a Space Leak (Was: [Haskell-cafe] about Haskell code written to be too smart)

2009-03-26 Thread Jonathan Cast
On Thu, 2009-03-26 at 12:29 -0700, Thomas Hartman wrote:
  I wonder if JHC
  or some other compiler might work better with these examples?
 
 Are you saying that different compilers might give different answers?
 
 Yikes!
 
 Too clever indeed!

No, they might produce code with different performance characteristics.

Which is very much what you want; there is no way to compile Haskell
such that reasonable-looking code is

 a) Fast and
 b) Predictably performant.

The idea of Haskell is to abstract away from the predictable performance
of the code by a) using a good compiler, and b) putting absolute
un-questioning faith in your profiler.

jcc


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: mapM as a Space Leak (Was: [Haskell-cafe] about Haskell code written to be too smart)

2009-03-26 Thread Thomas Hartman
Well, that's reassuring.

The reason I asked is that the testp function didn't just show poor
performance. The state monad implementation actually gave a different
answer -- nonterminating, where the pattern matching solution
terminated.

2009/3/26 Jonathan Cast jonathancc...@fastmail.fm:
 On Thu, 2009-03-26 at 12:29 -0700, Thomas Hartman wrote:
  I wonder if JHC
  or some other compiler might work better with these examples?

 Are you saying that different compilers might give different answers?

 Yikes!

 Too clever indeed!

 No, they might produce code with different performance characteristics.

 Which is very much what you want; there is no way to compile Haskell
 such that reasonable-looking code is

  a) Fast and
  b) Predictably performant.

 The idea of Haskell is to abstract away from the predictable performance
 of the code by a) using a good compiler, and b) putting absolute
 un-questioning faith in your profiler.

 jcc



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe