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

Implement a format-like syntax extension. #3

Open
Drup opened this issue Apr 27, 2015 · 2 comments
Open

Implement a format-like syntax extension. #3

Drup opened this issue Apr 27, 2015 · 2 comments

Comments

@Drup
Copy link
Owner

Drup commented Apr 27, 2015

Using ppx, it should be rather easy to do. Something of the form:

{furl|foo.org/bar/%i*?babar=%f?|furl}

This would allow to keep a readable syntax while avoiding the value restriction, since we would build the value directly (instead of using the combinators).

For matching, something along the lines of

match%furl uri with
  | {|....|} x y z -> body
  | _ -> default
@Drup
Copy link
Owner Author

Drup commented Jun 7, 2015

It appears that '?' for the option is troublesome. It conflicts with end-of-path '?' which makes the syntax clumsy and prevent usage of uri.

The matching syntax was rather trivial to implement.

An interesting point is that we could change the above snipet to something like that:

match%furl uri with
  | {|foo.com/{label:x}|}  -> ... do_something label ....
  | _ -> default

We could also use a similar syntax to provide labeled construction function but I'm afraid there will be weird constraints, much like Lwt_log's syntax extension.

Another issue is that I don't see how to compose existing piece of furl inside the ppx, which is pretty much the opposite of furl's objective.

@Drup
Copy link
Owner Author

Drup commented Oct 7, 2015

An interesting lead is URI templates, see an implementation and the RFC.

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

1 participant