#2754: Strictness analyzer fails on an implementation of foldl
-----------------------------+----------------------------------------------
 Reporter:  nimnul           |          Owner:         
     Type:  feature request  |         Status:  closed 
 Priority:  normal           |      Milestone:         
Component:  Compiler         |        Version:  6.8.3  
 Severity:  normal           |     Resolution:  invalid
 Keywords:                   |     Difficulty:  Unknown
 Testcase:                   |   Architecture:  x86    
       Os:  Windows          |  
-----------------------------+----------------------------------------------
Comment (by simonpj):

 I think you're suggesting the following: if the compiler sees `foldl`
 applied to a strict function, use a {{{foldl'}}} instead.  That's a
 reasonable suggestion but tricky for the compiler to automate.  It would
 have to (a) spot the opportunity, (b) generate a specialised version
 (that's {{{foldl'}}}), and (c) spot applications of `foldl` to a strict
 function, and use the specialised version.

 That's a big ask.  GHC is not clever enough to do any of these three!
 Even (c) is tricky: GHC's current rule matcher doesn't take strictness
 into account.  Would it matter if the function was only strict in its
 first argument?  Or its second?

 You sensibly suggest that (a), at least, might be programmer driven. But
 even then you need a language in which the programm can express the intent
 (how to say "generate a specialised version for a bi-strict function
 argument"?).  And there's still (b) and (c) to worry about.

 So while yes, we're very open to suggestions for improvements, I don't see
 how to take action on this one.  However two methods are already
 supported:

   * Write the function non-recursively, as Don suggests.  Then it can be
 inlined at every use site, which generates a very specialised copy!

   * Use Template Haskell; this is the direct analogue of what you do with
 template functions in C++

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2754#comment:11>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to