Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Week2: 4 and 5 #4

Open
BertLisser opened this issue Sep 22, 2017 · 4 comments
Open

Week2: 4 and 5 #4

BertLisser opened this issue Sep 22, 2017 · 4 comments

Comments

@BertLisser
Copy link

Exercise 4

instance Arbitrary RandomIntListSmall where
arbitrary = fmap RandomIntListSmall [(elements [1..10])]

doesn't work

Couldn't match expected type `[Int]' with actual type `Gen a0'
    In the return type of a call of `sublistOf'
    In the expression: (sublistOf[1 .. 10])
    In the second argument of `fmap', namely `[(sublistOf[1 .. 10])]'

must become

arbitrary = do
                   x<-(sublistOf[1..10])
                  return (RandomIntListSmall  x)

I don't understand how your code was able to run.
But the rest and approach was good.

Good

Exercise 5

Perfect

@Oipo
Copy link
Contributor

Oipo commented Sep 22, 2017

Regarding exercise 4, I am unsure where you see

instance Arbitrary RandomIntListSmall where
arbitrary = fmap RandomIntListSmall [(elements [1..10])]

As in the latest commit of the submitted Lab 2.hs file(5:41 PM, Sep 17 GMT +2) this is what is used for exercise 4:

data RandomIntListSmall = RandomIntListSmall [Int] deriving Show
instance Arbitrary RandomIntListSmall where
arbitrary = fmap RandomIntListSmall (sublistOf [1..10])

Could you check whether you have the latest code or if you've accidentally commented on the wrong group's code?

@BertLisser
Copy link
Author

Sorry if have changed sublistOf in elements. I thought that it was a problem of sublistOf. But that was not the case.
I tested it first with:

    instance Arbitrary RandomIntListSmall where
    arbitrary = fmap RandomIntListSmall (sublistOf [1..10])

These lines are in ST2017_WG_12/submission/lab 2/Lab 2.hs

@Oipo
Copy link
Contributor

Oipo commented Sep 22, 2017

That's odd. I just loaded it in ghci and it works fine. I'm using ghci 7.10.3 with quickcheck 2.10.0.1:

oipo@oipo-B85M-HD3 ~/Documents/UvA/master/Software Testing/ST2017_WG_12/submission/lab 2 $ ghci
GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
Prelude> :load "Lab 2.hs"
[1 of 1] Compiling Lab2             ( Lab 2.hs, interpreted )
Ok, modules loaded: Lab2.
*Lab2> exerciseFour 
"True"
+++ OK, passed 100 tests.
Success {numTests = 100, labels = [], output = "+++ OK, passed 100 tests.\n"}
*Lab2>
oipo@oipo-B85M-HD3 ~/Documents/UvA/master/Software Testing/ST2017_WG_12/submission/lab 2 $ cabal info quickcheck | grep installed
    Versions installed: 2.10.0.1

@BertLisser
Copy link
Author

I have install a new quickcheck (2.10.0.1) and exercise 4 works. I am curious to hear from you why. I must confess that I did't know this construct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants