Prelude.!! is not a good consumer
I think we can probably do something like this, but I haven't checked the Core yet:
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)
Trac metadata
Trac field | Value |
---|---|
Version | 7.8.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | libraries/base |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | ekmett, hvr |
Operating system | |
Architecture |