[vector] #51: optimization of fst . unzip . zip

vector vector at projects.haskell.org
Wed Mar 2 15:11:08 GMT 2011


#51: optimization of fst . unzip . zip
------------------------+---------------------------------------------------
Reporter:  choener      |       Owner:                        
    Type:  enhancement  |      Status:  new                   
Priority:  minor        |   Milestone:                        
 Version:  0.7          |    Keywords:  code-path optimization
------------------------+---------------------------------------------------
 Hi,

 lets assume this:
 {{{
 f n = map (\(a,b) -> (a+1,b+1)) . zip (enumFromN 0 n) (enumFromN 0 n)
 g = fst . unzip

 main = print . sum . g . f $ 100
 }}}

 In this case i would like to have {{{sum . g . f}}} reduce to {{{sum .
 enumFromN 0}}} but this does not happen. Is it in any way possible to get
 the optimizer to "cut out" unused code paths? The map operation in "f n"
 is basically a placeholder for something complicated.

 If this is possible to optimize correctly, it becomes possible to nicely
 describe some complicated code paths.

-- 
Ticket URL: <http://trac.haskell.org/vector/ticket/51>
vector <http://trac.haskell.org/vector>
Package vector


More information about the vector mailing list