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

Improve showing functions #11

Closed
UnkindPartition opened this issue Jan 25, 2013 · 5 comments
Closed

Improve showing functions #11

UnkindPartition opened this issue Jan 25, 2013 · 5 comments

Comments

@UnkindPartition
Copy link
Collaborator

First, provide a Fun datatype which knows about the function structure and show it instead.

Second, implement either function shrinking as described by Klaessen, or lazy-smallcheck-like shrinking.

@pepeiborra
Copy link

Perhaps the current instance for a->b should live in a separate module so that it can be optionally imported ?

@UnkindPartition
Copy link
Collaborator Author

It would be nice indeed, but this instance is needed to be able to test higher-order functions.

(Note the Show constraint in instance (Serial m a, Show a, Testable m b) => Testable m (a->b).)

@UnkindPartition
Copy link
Collaborator Author

This has now become a real problem.

Some of tasty's dependencies (I don't know which one) apparently imports Text.Show.Functions which contains a conflicting Show instance for function. So an attempt to use tasty and test functions using smallcheck results in an error:

Overlapping instances for Show (Bool -> JT Bool Maybe Bool)
  arising from a use of `testProperty'
Matching instances:
  instance [safe] Show (a -> b) -- Defined in `Text.Show.Functions'
  instance [overlap ok] (Serial Identity a, Show a, Show b) =>
                        Show (a -> b)
    -- Defined in `Test.SmallCheck.Series'

So, I'm going to remove the Show (a -> b) instance and replace it with a Show Fun instance.

@UnkindPartition
Copy link
Collaborator Author

Here are two approaches that I can think of:

  • When generating a function, store the additional information (such as the inspected size of the argument and the default value) so that we know what/how to show
  • Use the LogicT continuations to "refine" the function akin to lazy smallcheck. First try with the a never defined function, then catch exceptions and add cases to the table. This will work only with first-order functions, but OTOH it will produce much better results

I'm tempted to implement both approaches, like QuickCheck does (CoArbitrary vs Argument).

@Bodigrim
Copy link
Owner

Bodigrim commented Jun 1, 2023

I think that modern QuickCheck-like frameworks with powerful shrinking such as falsify offer a smoother user experience than smallcheck. I'll carry on with life support of smallcheck, but not really interested in changing things. Closing, won't do.

@Bodigrim Bodigrim closed this as completed Jun 1, 2023
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

3 participants