Skip to content
This repository has been archived by the owner on Nov 18, 2023. It is now read-only.

Monoid applicative tests #28

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

octopuscabbage
Copy link
Contributor

This PR is downstream from #21 and #27

@octopuscabbage
Copy link
Contributor Author

I just realized I'm a dingus and couldn't get the applicative tests to run becuase I never gave the functions a type constraint.

@octopuscabbage
Copy link
Contributor Author

We're good now

@Daniel-Diaz
Copy link
Owner

Those tests for applicative laws are not valid. They use 1x1 matrices, but the size must be arbitrary (within a reasonable range). Matrix is instance of Arbitrary, so it shouldn't be that hard.

Also... Branch conflicts? I just accepted your other patch, so this is weird. :octocat:

@octopuscabbage
Copy link
Contributor Author

The problem I was having was generating Arbitrary matricies of functions. I suppose I could write a custom instance

@Daniel-Diaz
Copy link
Owner

Check CoArbitrary.

@Daniel-Diaz
Copy link
Owner

In particular, if a is instance of CoArbitrary, and b is instance of Arbitrary, then a -> b is instance of Arbitrary.

In other words: (CoArbitrary a, Arbitrary b) => Arbitrary (a -> b).

This gives you Arbitrary instance for Matrix (a -> b).

@octopuscabbage
Copy link
Contributor Author

well that's a lot easier than what i was doing

@Daniel-Diaz
Copy link
Owner

Yeah, you don't have to do anything. Int is coarbitrary, so just use the matrices with the right type (like Matrix (Int ->Int)).

@octopuscabbage
Copy link
Contributor Author

I'm getting a weird error where it's saying that (Int -> Int) isn't showable

@Daniel-Diaz
Copy link
Owner

True... The argument of the property function you are testing must be instance of Show(so that counterexamples show up in screen when found). At the moment, it's fine to just add dummy instance for functions. I can improve it later.

@octopuscabbage
Copy link
Contributor Author

I went ahead and wrote a dummy instance of show for (Int->Int). This required turning on flexible instances in the testing source but it shouldn't be an issue since it's only test.

We might want to constrain down the functions to a finite type (Bool -> Bool) then we could write actual instances for show for that type.

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

Successfully merging this pull request may close these issues.

2 participants