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

the s/Num clause has interesting inheritance properties #15

Open
gfredericks opened this issue Jun 22, 2015 · 1 comment
Open

the s/Num clause has interesting inheritance properties #15

gfredericks opened this issue Jun 22, 2015 · 1 comment

Comments

@gfredericks
Copy link
Contributor

(schema->gen BigDecimal) returns a generator of floats, when I'd prefer that it would crash because it doesn't know how to generate BigDecimal.

The reason it does this is because the s/Num clause is using the java.lang.Number class which is a superclass of BigDecimal.

I think inheritance for generators kind of works in the opposite direction (IS THIS WHAT CONTRAVARIANT MEANS??).

Not sure what the best fix is. Only idea I have is swapping s/Num for Double.

@gfredericks
Copy link
Contributor Author

also worth pointing out that once I add my own (defmethod schema->gen BigDecimal ...) everything is fine -- the problem is just that I was confused prior to adding it.

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

1 participant