[Haskell-cafe] instance Enum [Char] where ...
tom.davie at gmail.com
Tue Dec 30 10:51:36 EST 2008
Am 30.12.2008 um 04:25 schrieb JustinGoguen:
> I am having difficulty making [Char] an instance of Enum. fromEnum
> is easy
> enough: map fromEnum to each char in the string and take the sum.
> toEnum has no way of knowing what the original string was.
The problem you're having is that your implementation does not
correctly enumerate lists of characters – in order to do so correctly,
you must not create the clashes you get with (for example "ab" and
I'd suggest rethinking how you would enumerate such strings.
More information about the Haskell-Cafe