[Haskell-cafe] Why the exception?
skynare at gmail.com
skynare at gmail.com
Tue Jun 24 23:58:01 EDT 2008
Probably you need to implement coarbitrary, too.
My ghci session for your code:
$ ghci
GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
Prelude> :l t.hs
[1 of 1] Compiling Main ( t.hs, interpreted )
t.hs:4:0:
Warning: No explicit method nor default method for `coarbitrary'
In the instance declaration for `Arbitrary L.ByteString'
Ok, modules loaded: Main.
*Main> quickCheck prop_LPS
Loading package array-0.1.0.0 ... linking ... done.
Loading package bytestring-0.9.0.1 ... linking ... done.
Loading package old-locale-1.0.0.0 ... linking ... done.
Loading package old-time-1.0.0.0 ... linking ... done.
Loading package random-1.0.0.0 ... linking ... done.
Loading package QuickCheck-1.1.0.0 ... linking ... done.
OK, passed 100 tests.
On 6/24/08, Thomas M. DuBuisson <thomas.dubuisson at gmail.com> wrote:
> Cafe
> I'm a bit lost on this exception and curious about what's going on. Is
> there a valid reason for this exception that I am missing? Note the
> hard-coded [0..100] could be any Word8 list you want (generated via
> arbitrary, [], or other) and it gives the same result.
>
> Load the module and perform:
> :break prop_LPS
> quickCheck prop_LPS
> :step
> :force ps
> *** Exception: Prelude.head: empty list
>
>> import qualified Data.ByteString as L
>> import Test.QuickCheck
>>
>> instance Arbitrary L.ByteString where
>> arbitrary = do
>> return $ L.pack [0..100]
>>
>> prop_LPS :: L.ByteString -> Bool
>> prop_LPS ps = ps `seq` True
>
> P.S. Same result with GHCi 6.8.2 and 6.8.3.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
More information about the Haskell-Cafe
mailing list