Re: [Haskell-cafe] Quick Question for QuickCheck2
You can create a wrapper with a newtype and then define an instance for that. newtype Char2 = Char2 Char instance Arbitrary Char2 where arbitrary = ... You'll have to do some wrapping and unwrapping when calling your properties to get/set the underlying Char, but this is probably the easiest way to 'constrain' the possible arbitrary results when the default instance for Char can be "too much." On Mon, Aug 30, 2010 at 10:12 AM, Sebastian Höhn wrote: > Hello, > > perhaps I am just blind or is it a difficult issue: I would like to > generate Char values in a given Range for QuickCheck2. There is this > simple example from the haskell book: > > instance Arbitrary Char where > arbitrary = elements (['A'..'Z'] ++ ['a' .. 'z'] ++ " ~...@#$%^&*()") > > This does not work in QuickCheck2 since the instance is already > defined. How do I achieve this behaviour in QC2? > > Thanks for helping. > > Sebastian > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- - Austin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Quick Question for QuickCheck2
Define a custom element generator, which has characters with your desired values: myRange :: Gen Char myRange = elements (['A'..'Z'] ++ ['a' .. 'z'] ++ " ~...@#$%^&*()") You can use "forAll" to run tests with a specific generator: forAll myRange $ \c -> chr (ord c) == c On Mon, Aug 30, 2010 at 08:12, Sebastian Höhn wrote: > Hello, > > perhaps I am just blind or is it a difficult issue: I would like to > generate Char values in a given Range for QuickCheck2. There is this > simple example from the haskell book: > > instance Arbitrary Char where > arbitrary = elements (['A'..'Z'] ++ ['a' .. 'z'] ++ " ~...@#$%^&*()") > > This does not work in QuickCheck2 since the instance is already > defined. How do I achieve this behaviour in QC2? > > Thanks for helping. > > Sebastian > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Quick Question for QuickCheck2
I'm just trying these examples, and I can't figure out how to import quickcheck2 rather than quickcheck1. I've looked around but I can't seem to find any information on this. How do I do it? Thanks! On Mon, Aug 30, 2010 at 11:56 PM, John Millikin wrote: > Define a custom element generator, which has characters with your > desired values: > > myRange :: Gen Char > myRange = elements (['A'..'Z'] ++ ['a' .. 'z'] ++ " ~...@#$%^&*()") > > You can use "forAll" to run tests with a specific generator: > > forAll myRange $ \c -> chr (ord c) == c > > On Mon, Aug 30, 2010 at 08:12, Sebastian Höhn > wrote: >> Hello, >> >> perhaps I am just blind or is it a difficult issue: I would like to >> generate Char values in a given Range for QuickCheck2. There is this >> simple example from the haskell book: >> >> instance Arbitrary Char where >> arbitrary = elements (['A'..'Z'] ++ ['a' .. 'z'] ++ " ~...@#$%^&*()") >> >> This does not work in QuickCheck2 since the instance is already >> defined. How do I achieve this behaviour in QC2? >> >> Thanks for helping. >> >> Sebastian >> ___ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Quick Question for QuickCheck2
Update your cabal package list, and then install QuickCheck. Optionally, you can use a version specifier: cabal update cabal install 'QuickCheck >= 2' This should make QuickCheck 2 the default in GHCI. If it doesn't, you may need to specify the version: ghci -package QuickCheck-2.2 For Cabal-packaged libraries/applications, simply update your version requirements. On Mon, Aug 30, 2010 at 09:06, Lyndon Maydwell wrote: > I'm just trying these examples, and I can't figure out how to import > quickcheck2 rather than quickcheck1. I've looked around but I can't > seem to find any information on this. How do I do it? > > Thanks! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Quick Question for QuickCheck2
Thanks! This makes perfect sense, but as I just discovered using ghci -v there is an even stranger problem. I'm side-tracking slightly from the original question here, but nevertheless... GHC gives the following output: --- GHCi, version 6.12.3: http://www.haskell.org/ghc/ :? for help : cannot satisfy -package QuickCheck-2.1.1.1: QuickCheck-2.1.1.1-c7435cb0d5b5de72fe9540c48335606d is unusable due to missing or recursive dependencies: ghc-6.12.3-66a382195c8a71849653439b67021fd1 (use -v for more information) shell returned 1 --- However I am using the version of GHC mentioned, so I have no idea what is going on. On Tue, Aug 31, 2010 at 1:09 AM, John Millikin wrote: > Update your cabal package list, and then install QuickCheck. > Optionally, you can use a version specifier: > > cabal update > cabal install 'QuickCheck >= 2' > > This should make QuickCheck 2 the default in GHCI. If it doesn't, you > may need to specify the version: > > ghci -package QuickCheck-2.2 > > For Cabal-packaged libraries/applications, simply update your version > requirements. > > > On Mon, Aug 30, 2010 at 09:06, Lyndon Maydwell wrote: >> I'm just trying these examples, and I can't figure out how to import >> quickcheck2 rather than quickcheck1. I've looked around but I can't >> seem to find any information on this. How do I do it? >> >> Thanks! > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Quick Question for QuickCheck2
On 31 August 2010 03:18, Lyndon Maydwell wrote: > Thanks! > > This makes perfect sense, but as I just discovered using ghci -v there > is an even stranger problem. I'm side-tracking slightly from the > original question here, but nevertheless... > > GHC gives the following output: > > --- > GHCi, version 6.12.3: http://www.haskell.org/ghc/ :? for help > : cannot satisfy -package QuickCheck-2.1.1.1: > QuickCheck-2.1.1.1-c7435cb0d5b5de72fe9540c48335606d is unusable > due to missing or recursive dependencies: > ghc-6.12.3-66a382195c8a71849653439b67021fd1 > (use -v for more information) > > shell returned 1 What does "ghc-pkg check" say? To me, it sounds like you upgraded a boot library, which is a big no-no. (The ghc mentioned here is the ghc library, not the compiler itself.) -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Quick Question for QuickCheck2
ghc-pkg check doesn't list any broken dependencies. On Tue, Aug 31, 2010 at 9:27 AM, Ivan Lazar Miljenovic wrote: > On 31 August 2010 03:18, Lyndon Maydwell wrote: >> Thanks! >> >> This makes perfect sense, but as I just discovered using ghci -v there >> is an even stranger problem. I'm side-tracking slightly from the >> original question here, but nevertheless... >> >> GHC gives the following output: >> >> --- >> GHCi, version 6.12.3: http://www.haskell.org/ghc/ :? for help >> : cannot satisfy -package QuickCheck-2.1.1.1: >> QuickCheck-2.1.1.1-c7435cb0d5b5de72fe9540c48335606d is unusable >> due to missing or recursive dependencies: >> ghc-6.12.3-66a382195c8a71849653439b67021fd1 >> (use -v for more information) >> >> shell returned 1 > > What does "ghc-pkg check" say? > > To me, it sounds like you upgraded a boot library, which is a big no-no. > > (The ghc mentioned here is the ghc library, not the compiler itself.) > > -- > Ivan Lazar Miljenovic > ivan.miljeno...@gmail.com > IvanMiljenovic.wordpress.com > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Quick Question for QuickCheck2
On 31 August 2010 20:38, Lyndon Maydwell wrote: > ghc-pkg check doesn't list any broken dependencies. You sure this is with the same user? ghci is unlikely to complain about broken libraries if ghc-pkg check doesn't... -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Quick Question for QuickCheck2
Yep. Definitely the same user. On Tue, Aug 31, 2010 at 7:35 PM, Ivan Lazar Miljenovic wrote: > On 31 August 2010 20:38, Lyndon Maydwell wrote: >> ghc-pkg check doesn't list any broken dependencies. > > You sure this is with the same user? ghci is unlikely to complain > about broken libraries if ghc-pkg check doesn't... > > -- > Ivan Lazar Miljenovic > ivan.miljeno...@gmail.com > IvanMiljenovic.wordpress.com > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Quick Question for QuickCheck2
Do you have ~/.cabal/bin/ in your PATH? - Sebastian Am 31.08.2010 um 15:57 schrieb Lyndon Maydwell: > Yep. Definitely the same user. > > On Tue, Aug 31, 2010 at 7:35 PM, Ivan Lazar Miljenovic > wrote: >> On 31 August 2010 20:38, Lyndon Maydwell wrote: >>> ghc-pkg check doesn't list any broken dependencies. >> >> You sure this is with the same user? ghci is unlikely to complain >> about broken libraries if ghc-pkg check doesn't... >> >> -- >> Ivan Lazar Miljenovic >> ivan.miljeno...@gmail.com >> IvanMiljenovic.wordpress.com >> > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Quick Question for QuickCheck2
Yep :) Is there a batch of information that might be useful? I can send any relevant files, aliases, versions, etc at once to help if you like. On Wed, Sep 1, 2010 at 12:35 AM, Sebastian Höhn wrote: > > Do you have ~/.cabal/bin/ in your PATH? > > - Sebastian > > Am 31.08.2010 um 15:57 schrieb Lyndon Maydwell: > >> Yep. Definitely the same user. >> >> On Tue, Aug 31, 2010 at 7:35 PM, Ivan Lazar Miljenovic >> wrote: >>> On 31 August 2010 20:38, Lyndon Maydwell wrote: ghc-pkg check doesn't list any broken dependencies. >>> >>> You sure this is with the same user? ghci is unlikely to complain >>> about broken libraries if ghc-pkg check doesn't... >>> >>> -- >>> Ivan Lazar Miljenovic >>> ivan.miljeno...@gmail.com >>> IvanMiljenovic.wordpress.com >>> >> ___ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Quick Question for QuickCheck2
Do you have ~/.cabal/bin or $HOME/.cabal/bin ? The latter is preferable as some issues arise with the former... On 1 September 2010 03:29, Lyndon Maydwell wrote: > Yep :) > > Is there a batch of information that might be useful? I can send any > relevant files, aliases, versions, etc at once to help if you like. > > On Wed, Sep 1, 2010 at 12:35 AM, Sebastian Höhn > wrote: >> >> Do you have ~/.cabal/bin/ in your PATH? >> >> - Sebastian >> >> Am 31.08.2010 um 15:57 schrieb Lyndon Maydwell: >> >>> Yep. Definitely the same user. >>> >>> On Tue, Aug 31, 2010 at 7:35 PM, Ivan Lazar Miljenovic >>> wrote: On 31 August 2010 20:38, Lyndon Maydwell wrote: > ghc-pkg check doesn't list any broken dependencies. You sure this is with the same user? ghci is unlikely to complain about broken libraries if ghc-pkg check doesn't... -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com >>> ___ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> ___ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Quick Question for QuickCheck2
$HOME/.cabal/bin On Wed, Sep 1, 2010 at 10:55 AM, Ivan Lazar Miljenovic wrote: > Do you have ~/.cabal/bin or $HOME/.cabal/bin ? The latter is > preferable as some issues arise with the former... > > On 1 September 2010 03:29, Lyndon Maydwell wrote: >> Yep :) >> >> Is there a batch of information that might be useful? I can send any >> relevant files, aliases, versions, etc at once to help if you like. >> >> On Wed, Sep 1, 2010 at 12:35 AM, Sebastian Höhn >> wrote: >>> >>> Do you have ~/.cabal/bin/ in your PATH? >>> >>> - Sebastian >>> >>> Am 31.08.2010 um 15:57 schrieb Lyndon Maydwell: >>> Yep. Definitely the same user. On Tue, Aug 31, 2010 at 7:35 PM, Ivan Lazar Miljenovic wrote: > On 31 August 2010 20:38, Lyndon Maydwell wrote: >> ghc-pkg check doesn't list any broken dependencies. > > You sure this is with the same user? ghci is unlikely to complain > about broken libraries if ghc-pkg check doesn't... > > -- > Ivan Lazar Miljenovic > ivan.miljeno...@gmail.com > IvanMiljenovic.wordpress.com > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> ___ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> ___ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > -- > Ivan Lazar Miljenovic > ivan.miljeno...@gmail.com > IvanMiljenovic.wordpress.com > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe