Doug McIlroy points out:

| trivial bug (inaccurate error comment) in Prelude.hs:
|
| Prelude> ([]::[Int]) !! -1
|
| Program error: PreludeList.!!: index too large

This is really a bug in the Haskell report, which defines (!!) thus:

(x:_)  !! 0             =  x
(_:xs) !! n | n > 0     =  xs !! (minusInt n 1)
(_:_)  !! _             =  error "Prelude.(!!): negative index"
[]     !! _             =  error "Prelude.(!!): index too large"

I propose to treat this as another H98 Report typo, and change the defn to

xs  !! n    | n < 0         =  error "Prelude.(!!): negative index"
[]     !! _             =  error "Prelude.(!!): index too large" 
(x:_)  !! 0             =  x
(_:xs) !! n | n > 0     =  xs !! (minusInt n 1)


Does anyone object?

(I'm still trying to get round to consolidating the H98 revisions into a
revised
report.)

Simon

Reply via email to