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

Add a FromParam instance for String #15

Open
emhoracek opened this issue Aug 3, 2017 · 2 comments
Open

Add a FromParam instance for String #15

emhoracek opened this issue Aug 3, 2017 · 2 comments

Comments

@emhoracek
Copy link
Member

emhoracek commented Aug 3, 2017

FromParam has instances for some common types, but it doesn't have an instance for String. That's not such a big deal, because usually it's nicer to use Text. But since a lot of functions from Prelude still use String, it makes sense to let users have String params as well.

Adding a String instance will let people write a route like this:

route ctxt [ path "hello" // param "name" ==> helloHandler ]

and a handler like this:

helloHandler :: Ctxt -> String -> IO (Maybe Response)
helloHandler ctxt name = 
  let helloMessage = T.pack ("Hello " ++ name) in 
    okText helloMessage

And when you went to "/hello?name=Suzy", you would see "Hello Suzy".

Right now, you would get an error that there's no FromParam instance for String.

@arbuztw
Copy link

arbuztw commented Oct 1, 2017

Hi! I came across this project through the hacktoberfest label. I was wondering if I could take this?

@emhoracek
Copy link
Member Author

@arbuztw go for it! I forgot to mention above -- you'll also want to add a test to fn/test/Spec. Let me know if you have any questions.

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

No branches or pull requests

2 participants