[QuickCheck] Positive instance is broken
Nick Smallbone
nicsma at chalmers.se
Sun Jun 8 21:16:56 BST 2014
Ah, bugger. What happens is that showHex has a base case when its
argument is 0, which desugars into a comparison with fromInteger 0 --
but since Positive's fromInteger doesn't allow you to construct
non-positive numbers, this case never matches.
I think I'll have to do what I was trying to avoid, and remove the Num
instance for Positive and friends entirely. It doesn't really make
sense to have a numeric type without 0 in it. This means that your
earlier bug report, about Small (Positive Int), will now fail to
typecheck, but Positive (Small Int) will do the right thing.
Nick
On Thursday 05 June, 2014 at 09:57 pm, Bryan O'Sullivan wrote:
> This goes into an infinite loop in ghci:
>
> >>> import Numeric
> >>> import Test.QuickCheck
> >>> showHex (1 :: Positive Int) ""
> _______________________________________________
> QuickCheck mailing list
> QuickCheck at projects.haskell.org
> http://projects.haskell.org/cgi-bin/mailman/listinfo/quickcheck
More information about the QuickCheck
mailing list