
On Sun, Jul 29, 2012 at 12:38 PM, Antoine Latter
On Sun, Jul 29, 2012 at 11:37 AM, Antoine Latter
wrote: The downside to this proposal is that the requester (Edward) actually wants a function of type "a -> Maybe Int", so his polymorphic function can handle both infinite bit-types and finite bit-types.
With the new class, Edward could write:
class BitTraversable i where traverseBits :: <sometype>
instance (BitSize i) => BitTraversable i where traverseBits = <something>
instance BitTraversable Integer where traverseBits = <something else>
I should add that this approach looks like it would require OverlappingInstances.
Correct. This is not a viable solution for the problem, also it precludes the existance of support for someone else's Natural number type, etc. Every type that is currently an instance of Bits is either of a fixed size or potentially infinite. Changing bitSize to return a Maybe a works. Making a separate BitSize class simply forces me to do exactly what I'm doing right now, which is ignore it and manually probe. I'm a strong -1 vote to any solution that splits BitSize out into a separate class. -Edward