
On Sat, Oct 15, 2011 at 08:00:21PM +0200, Bas van Dijk wrote:
We can also combine Gábor's and Roman's solutions to get both portability and convenience:
zero, one :: a
#ifdef __GLASGOW_HASKELL__ default zero, one :: Num a => a zero = 0 one = 1 #endif
I think doing this conditionally is a bad idea. Programs will just fail at runtime when using other impls. I also think doing it unconditionally is a bad idea. It significantly raises the barrier to getting another impl to the point where it is useful. Hmm, one can be (bit 0) though. I don't think zero is anything nicer than (clearBit (bit 0) 0). (I don't know what the rules are about using those functions with arguments > bitSize, so I don't know if that would be valid for hypothetical bitSize == 0 instances like ()). Thanks Ian