Yes, there is a special function that can add to Char from the same Enum class from which enumFromTo is named succ . Remember that it is partial: succ maxBound is undefined, so take care of the meaning of the character before applying succ . succ really matches \c -> chr (ord c + 1) , as you can check with the universe package:
> let avoidMaxBound fx = if x == maxBound then Nothing else Just (fx) > avoidMaxBound succ == avoidMaxBound (\c -> chr (ord c + 1)) True
In fact, the succ implementation in GHC is pretty close to the function you suggested:
instance Enum Char where succ (C# c#) | isTrue# (ord# c# /=# 0x10FFFF#) = C# (chr# (ord# c# +# 1#)) | otherwise = error ("Prelude.Enum.Char.succ: bad argument")
However, succ not used in the enumFromTo implementation in the GHC:
instance Enum Char where {-
If you can squint due to muck, which exists primarily for efficiency reasons, you can see that eftChar essentially uses succ , and the built-in version, rather than the actual call to succ (here, to avoid boxing and re-boxing when manipulating Char ) .
Daniel Wagner
source share