-
Notifications
You must be signed in to change notification settings - Fork 37
Other #3
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
Other #3
Conversation
|
I think it looks good. I can spend more time on this tonight and this weekend, but for now:
|
|
If we can't make errors into a semiring, maybe there's a middle ground where we introduce an ADT for single errors and use a list of errors to represent multiple failures in parallel. One last comment: consider using |
|
Why Errors are working perfectly as semiring. I switched to |
|
src/Routing/Types.purs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This representation doesn't seem to represent the fact that you only have one Query part. Why not
data Route = Route { parts :: List String, params :: M.StrMap String }There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foo/?bar=12/baz/?quux=123/ is not equal to foo/?bar=12&quux=123/baz/.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, sorry, I didn't realize you needed to support those cases. Isn't it more common to push the query parameters to the end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding support of multiple queries is easy, and it can be useful sometimes.
I.e. in producing parameterized ajax and filtering grid with many filters simultaneously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I'm not suggesting that there only be one query parameter. I just don't see the appeal of distinguishing foo/?bar=12/baz/?quux=123/ from foo/?bar=12&quux=123/baz/ as routes. I would normally expect query parameters to be put at the end, and for both of these to fail to parse:
foo/baz?bar=12&quux=123
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand. But I believe that ability of matching routes with many query parts is useful
|
Here is my suggestion for the representation of errors: https://gist.github.com/paf31/c4b5c06fab182073d533 It is the free semiring generated by a type. You can try it in > free 1
(Free [[1]])
> free 1 + free 2
(Free [[1],[2]])
> (free 1 + free 2) * free 3
(Free [[1,3],[2,3]])
> (free 1 + free 2) * (free 3 + free 4)
(Free [[1,3],[1,4],[2,3],[2,4]])
> (free 1 + free 2) * (free 3 + free 4) * (free 5 + free 6)
(Free [[1,3,5],[1,3,6],[1,4,5],[1,4,6],[2,3,5],[2,3,6],[2,4,5],[2,4,6]])
> liftFree id $ (free 1 + free 2) * (free 3 + free 4) * (free 5 + free 6)
231If you choose a base type |
|
@paf31 thank you free semiring is awesome :) |
|
Looking pretty good -- I agree the validation and free semiring stuff probably belongs elsewhere, but if we can't get those out now quickly, we can always do it after the fact. Any other comments / suggestions from @paf31 or @garyb? Is this ready to merge, @cryogenian?? |
|
Looks good to me, although a few more doc comments would probably help. I'd definitely take PRs on |
|
Yeah, I'd say add a |
|
👍 from me. A |
|
great! I'll make pr |
|
I just created this, in case you want to send a PR. If not, we can leave it for later. |
|
K, please also do a PR to semirings, it will add a small delay but hopefully @paf31 can approve & tag a version quickly. |
|
I think it's ready. (Maybe I made something wrong in |
|
Oops, my fault. |
|
It should be there now. |
|
Done |
|
|
I've tried to use
as an error, but first attempt have been very ugly, so I've revert it to
String.matchesfires whennewURLcan be parsed, ifoldURLcan not be parsed then it fires withNothingas first param.