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

Yesod add-handler functionality doesn't include arguments #898

Closed
MaxGabriel opened this Issue Dec 30, 2014 · 1 comment

Comments

Projects
None yet
2 participants
@MaxGabriel
Member

MaxGabriel commented Dec 30, 2014

Currently, the add-handler command from yesod-bin doesn't include arguments in the function implementation:

yesod add-handler
> Foo
> /test/#UserId
module Handler.Foo where

import Import

getFooR :: UserId -> Handler Html
getFooR = error "Not yet implemented: getFooR" -- no function argument here

While not necessary, it'd be nice if getFooR included the arguments:

getFooR :: UserId -> Handler Html
getFooR userId = error "Not yet implemented: getFooR"

I was thinking just lowercasing the first letter of the type would do it, i.e. UserId => userId. This doesn't work as well for generic types like Text (text), but seems better than nothing.

This would avoid a compiler error if you implement the function without the argument by mistake, reduces boilerplate, and promotes more consistent argument naming (e.g. BlogPostId consistently becomes blogPostId rather than blogpostId).

One issue with this approach is that people would get warnings for unused arguments. In this case, using underscores might be the best alternative:

getFooR :: UserId -> Handler Html
getFoorR _ = error "Not yet implemented: getFooR"

edit: or with a prefixed underscore

getFooR :: UserId -> Handler Html
getFoorR _userId = error "Not yet implemented: getFooR"
@snoyberg

This comment has been minimized.

Show comment
Hide comment
@snoyberg

snoyberg Dec 31, 2014

Member

Addressed by pull request

Member

snoyberg commented Dec 31, 2014

Addressed by pull request

@snoyberg snoyberg closed this Dec 31, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment