Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Add decode function. #12
What does this pull request do?
The purpose of this pull request is to extend the library with a function that decodes form data into the
Where should the reviewer start?
It's a pretty small change.
How should this be manually tested?
Here are my test cases:
I already updated the README, and I don't think any follow-up steps are necessary other than cutting a release.
Thanks for the response @thomashoneyman. I should have given more consideration to the possibility of
I think the main issue is that the type of
Another option would be to resort to the FFI as in purescript-httpure, but, actually, is this modeled correctly? I thought that throwing an error is considered a side effect. (As a relative PureScript newbie, I would love clarification one way or the other!) Assuming that throwing an error is a side effect, I think this would ultimately need to be reflected in the return types of
Yet another possibility would be to attempt to validate the input before calling
Please let me know what you think, or if you had another solution in mind. Maybe @garyb would be willing to opine as well, since I believe he has worked on purescript-uri and can see that he is keeping an eye on this issue. Otherwise, thanks again for the feedback!
I agree that ideally there should be non-unsafe version of
And yeah, an exception/
Thanks for the comprehensive response! @garyb made some good points; here are a few thoughts on my end:
This sounds like a problem to me. If encoding and decoding can fail then their types should reflect that -- likely through a
@garyb noted that there isn't error handling because the author(s) felt confident that they were providing input which would always succeed. So that's a sensible use of the unsafe functions. But it doesn't mean other code should do the same thing.
The use of
I think you've raised a good point -- if these are defined in the purescript-globals package, why not update that package's main namespace (
@garyb I don't see a reason why
Generally that's true -- throwing an error is a side effect -- but a
Updated test cases:
@garyb this is going to be a breaking change because of the type signature difference. Do you have an opinion on adding
EDIT: Whoops, meant to write this on #13.
@nsaunders actually, do you mind adding a
where each of your lines above would be an