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

Arbitrary Exp #1

Closed
Wizek opened this issue Jul 24, 2015 · 4 comments
Closed

Arbitrary Exp #1

Wizek opened this issue Jul 24, 2015 · 4 comments

Comments

@Wizek
Copy link

Wizek commented Jul 24, 2015

Hello!

Do I see it correctly that in this file you are defining an Arbitrary instance for Haskell AST? Could that be used to get arbitrary haskell source strings via QuickCheck? And if so perhaps would you be willing to move that portion out to a separate cabal package so that others, including myself could use it?

@RyanGlScott
Copy link
Owner

To be honest, that's some of the laziest Haskell code I've ever written. My goal when defining those Arbitrary instances was not to have robust generation of Haskell source strings, but to produce simple expressions that I could use to test TextShow instances.

The commented-out code was my original attempt, but due to the high levels of mutual recursion among Template Haskell data types, they were too slow for practical use. To get around this, I use trivial values for most types, which means any Haskell expressions generated by this code would be extremely uninteresting.

@Wizek
Copy link
Author

Wizek commented Jul 25, 2015

You mean the slowness came due to the recursion going too deep and generating too long of an AST? If so couldn't that be solved by allowing to specify the desired depth and/or length of the arbitrary expression?

A bit of context: I am thinking of using automatically generated expressions to test the correctness of this parser.

@RyanGlScott
Copy link
Owner

If so couldn't that be solved by allowing to specify the desired depth and/or length of the arbitrary expression?

Probably. I'm not an experienced QuickCheck user—I just needed a quick test for text-show-instances, and that was what I cobbled together. If you want to extend it, you're more than welcome to use that code as a start, but I don't really have the time to mess with it.

@RyanGlScott
Copy link
Owner

I'm going to close this, since it seems only tangentially related to text-show-instances.

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