furl icon indicating copy to clipboard operation
furl copied to clipboard

Implement a format-like syntax extension.

Open Drup opened this issue 10 years ago • 2 comments

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 avatar Apr 27 '15 05:04 Drup

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 avatar Jun 07 '15 02:06 Drup

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

Drup avatar Oct 07 '15 13:10 Drup