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

declareNamedSchema takes a concrete Proxy #180

Merged
merged 3 commits into from
Feb 27, 2019

Conversation

fieldstrength
Copy link
Contributor

Fixes #150

As mentioned on the issue, this would be especially valuable for enabling ToSchema to be derived with DerivingVia.

This would be a breaking change, but hopefully the actual incurred code updates would be minimal. Happily the code changes are quite small, and all the other functions besides declareNamedSchema continue to accept polymorphic proxys.

@fizruk fizruk requested a review from phadej February 24, 2019 22:05
declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions

-- | Convert a type into a schema and declare all used schema definitions.
declareSchema :: ToSchema a => proxy a -> Declare (Definitions Schema) Schema
declareSchema = fmap _namedSchemaSchema . declareNamedSchema
declareSchema :: forall a proxy. ToSchema a => proxy a -> Declare (Definitions Schema) Schema
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or should this functions use concrete Proxy too? I'm not sure.

  • The class member type-signature change is already a breaking change, so we can break more
  • is there value in consistency?

I'm quite sure I used some of of swagger2 combinators with not-Proxy, but it was indeed more of "cleverness" than strict requirement (i.e. look, I actually have Maybe a value here, I can plug).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fizruk opinions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point.

Changing them all has the advantage that nobody will be confused about this difference, even if it otherwise doesn't matter in any significant way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to switch to Proxy everywhere eventually. And since we are doing a breaking change, why not break all of it in the same way? 😊

Copy link
Collaborator

@phadej phadej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I'll accept this PR when all proxy-ies are changed to Proxy. Most importantly in ToParamSchema class too.

@fieldstrength
Copy link
Contributor Author

Alright @phadej, I believe this is now as you wanted.

@phadej phadej merged commit 29f720f into GetShopTV:master Feb 27, 2019
@phadej
Copy link
Collaborator

phadej commented Feb 27, 2019

Thanks!

@fieldstrength fieldstrength deleted the monomorphic-proxy branch February 28, 2019 12:29
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

Successfully merging this pull request may close these issues.

3 participants