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

Thomas Hartman tphyahoo at gmail.com
Thu Mar 26 15:29:01 EDT 2009


> 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  <roconnor at 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 at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list