[Haskell-cafe] Quickcheck examples and Data.Word32
Bryn Keller
xoltar at xoltar.org
Thu Oct 27 14:41:28 EDT 2005
I've not had any problems with them, though of course your mileage may
vary. Have a look at section 7.4.4.3 in
http://www.haskell.org/ghc/docs/latest/html/users_guide/type-extensions.html#multi-param-type-classes
for an explanation. Basically, if you have a cyclic class dependency
graph, the type checker won't terminate. Well, it will, but only because
there's a limit on the recursion depth. The trivial example is
instance C a => C a where ...
In practice, I'm not sure that this is really a big issue, and it does
come in handy. Perhaps someone who's actually been bitten by a problem
with undecidable instances can comment?
Bryn
Joel Reymont wrote:
> This requires
>
> {-# OPTIONS_GHC -fallow-undecidable-instances #-}
>
> but since I'm using -fglasgow-exts in a lot of places I'm wondering if
> adding undecidable instances would be a bad habit. I guess not... not
> until I shoot myself in the foot :-).
>
> Any explanation of undecidable instances, the good and the bad?
>
> Joel
>
> On Oct 27, 2005, at 6:49 PM, Bryn Keller wrote:
>
>> How about this?
>>
>> class ArbitraryDefault a where {}
>>
>> instance (Integral a, Bounded a, ArbitraryDefault a) => Arbitrary a
>> where
>> arbitrary = arbitraryBound
>> coarbitrary a = error "Not implemented"
>>
>> instance ArbitraryDefault Word16 instance ArbitraryDefault Word32
>> instance ArbitraryDefault Word64
>
> --
> http://wagerlabs.com/
>
>
>
>
>
>
>
More information about the Haskell-Cafe
mailing list