At the last minute, I have found some Enum bugs in 1.2.beta.
As I don't know if they have been fixed in 1.2.gamma, which
I guess was circulated yesterday, here they are:

   1) According to the specification (section 3.9), the
      value of

                [ 7, 7 .. 3 ]

      is the infinite list [ 7, 7, 7, 7,...], but the
      default definition of enumFromThenTo (pp. 30 and 91)
      gives the value

                takeWhile (<= 3) enumFromThen 7 7

      which is the empty list!

   2) Similarly, the value of

                ['z', 'y' .. 'a']

      should be the alphabete in reverse order, but according to
      the Enum instance of Char (p. 92), we get

          takeWhile (>= 'a') (map chr [ord 'z', ord 'y' .. ord maxChar]) ==
          takeWhile (>= 'a') (map chr []) ==
          [],

      i.e, also the empty list.

   Suggested fixes:

   1) The default definition of enumFromThenTo (pp. 30 and 91)
     should be:

     enumFromThenTo n n' m | n < n'  = takeWhile (<= m) (enumFromThen n n')
                           | n > n'  = takeWhile (>= m) (enumFromThen n n')
                           | n == n' = repeat n
                           | otherwise = error "enumFromThenTo{PreludeCore}: \
                                               \no ordering relation"

   2) The instance Enum Char (p. 92) should read:

     enumFromThen c c' | c < c'  = map chr [ord c, ord c' .. ord maxChar]
                       | c > c'  = map chr [ord c, ord c' .. ord minChar]
                       | otherwise = repeat c


-- Mikael R.

Reply via email to