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

Consider using makeFields, not makeLenses #39

Closed
fizruk opened this issue Jan 18, 2016 · 3 comments · Fixed by #41
Closed

Consider using makeFields, not makeLenses #39

fizruk opened this issue Jan 18, 2016 · 3 comments · Fixed by #41

Comments

@fizruk
Copy link
Member

fizruk commented Jan 18, 2016

HasParamSchema will still be useful.

makeFields should shorten many names in Data.Swagger.Lens.
For example it would turn this code:

swagDoc :: Swagger
swagDoc = toSwagger (Proxy :: Proxy API)
  & info.infoTitle .~ "Todo API"
  & info.infoVersion .~ "1.0"
  & info.infoDescription ?~ "This is an API that tests servant-swagger support for a Todo"
  & info.infoLicense ?~ License "MIT" (Just (URL "http://mit.com"))

into

swagDoc :: Swagger
swagDoc = toSwagger (Proxy :: Proxy API)
  & info.title .~ "Todo API"
  & info.version .~ "1.0"
  & info.description ?~ "This is an API that tests servant-swagger support for a Todo"
  & info.license ?~ License "MIT" (Just (URL "http://mit.com"))

@dmjio what do you think? Would this simplify customizing spec by a significant ammount?

@dmjio
Copy link
Collaborator

dmjio commented Jan 18, 2016

yea, this would be really cool, as long as we don't have any overlapping lenses. In that case it might be best to make a typeclass that contains a lens. (example: if title is found in more than one data type). And make instances for the respective types.

@fizruk
Copy link
Member Author

fizruk commented Jan 18, 2016

@dmjio makeFields will do exactly that! Check out its documentation :)

@dmjio
Copy link
Collaborator

dmjio commented Jan 18, 2016

oh that's beautiful, for some reason I was thinking of makeLenses. Looks perfect

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 a pull request may close this issue.

2 participants