[GHC] #9510: Prelude.!! is not a good consumer

GHC ghc-devs at haskell.org
Sat Aug 23 21:50:03 UTC 2014


#9510: Prelude.!! is not a good consumer
-------------------------------------+-------------------------------------
       Reporter:  dfeuer             |                   Owner:
           Type:  bug                |                  Status:  new
       Priority:  normal             |               Milestone:
      Component:  libraries/base     |                 Version:  7.8.3
       Keywords:  fusion             |        Operating System:
   Architecture:  Unknown/Multiple   |  Unknown/Multiple
     Difficulty:  Unknown            |         Type of failure:  Runtime
     Blocked By:                     |  performance bug
Related Tickets:                     |               Test Case:
                                     |                Blocking:
                                     |  Differential Revisions:
-------------------------------------+-------------------------------------
 I think we can probably do something like this, but I haven't checked the
 Core yet:

 {{{#!hs
 xs !! n
   | n < 0     = error "Prelude.!!: Negative index"
   | otherwise = foldr go (error "Prelude.!!: index too large or list
 empty") xs n
   where
     go x _ 0 = x
     go _ f k = f (k - 1)
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9510>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list