#3416: maximumBy uses too much stack
---------------------------------+------------------------------------------
    Reporter:  bdonlan           |        Owner:                  
        Type:  bug               |       Status:  closed          
    Priority:  normal            |    Milestone:                  
   Component:  libraries/base    |      Version:  6.10.4          
    Severity:  normal            |   Resolution:  wontfix         
    Keywords:                    |   Difficulty:  Unknown         
    Testcase:                    |           Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |  
---------------------------------+------------------------------------------
Changes (by igloo):

  * status:  new => closed
  * difficulty:  => Unknown
  * resolution:  => wontfix

Comment:

 This definition is not equivalent, e.g. compare `z1` and `z2` in
 {{{
 import Data.List

 maximumBy'               :: (a -> a -> Ordering) -> [a] -> a
 maximumBy' _ []          =  error "List.maximumBy: empty list"
 maximumBy' cmp xs        =  foldl1' maxBy xs
                         where
                            maxBy x y = case cmp x y of
                                        GT -> x
                                        _  -> y

 f _ _ = LT

 z1 = maximumBy  f [undefined, undefined, 1]
 z2 = maximumBy' f [undefined, undefined, 1]
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3416#comment:1>
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