-
Notifications
You must be signed in to change notification settings - Fork 56
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
interface is inconsistent #18
Comments
Would it be possible to think of a new convention here? I'm not against the convention but this feels like giving up early. Compatibility can always be preserved through aliases. @Drup @dbuenzli you guys are pretty good with naming stuff. Context: primed functions handle the query string as a For example: val with_query : t -> (string * string list) list -> t
val with_query' : t -> (string * string) list -> t |
Are you proposing the opposite convention of the initial proposal? I don't understand your comment about giving up early. If renames clash, aliases can't preserve compat... I think the idea with the initial proposal is that most users don't care about the minutiae of query string syntax and interpretation and therefore the unprimed version should be the simpler type. I'm not fond of having multiple similar functions differing only by Regardless of these issues, the current interface is not named consistently due to mistakes during the early development of the library. This should be fixed somehow. |
From the signature I vaguely understand the first, I don't understand the second one. However what I really don't understand is that if I remember correctly RFC 3986 defines |
Yes, query is opaque and these functions should be separated. |
I'm saying that the primed/unprimed convention is possibly giving up early because the convention is not at all descriptive of the distinction it's describing. For example, a convention like adding Unfortunately I can't think of any decent naming scheme. |
Agreed. Most likely we should expose the internal structure of the library which has each of the syntactic components as nested modules. When this design is refined for 2.0, a suffix will probably become clear. Maybe |
I would tend to give the primary function the most specific type, |
I don't like this. If ocaml-uri is a general library you want to be able to work with the structures of the standard as they are named by it. Key/values queries and their syntax are outside the scope of the standard and as such should be provided somewhere else and/or under different names. |
For example these things have absolutely nothing to do in the core URI interface in my opinion. |
My opinion is that the default interface should use types the most (we are not using a statically type language to encode everything in strings ...). Especially since it's more strict than the standard and that the more liberal functions are available. If functions were more loose than the standard, I would agree, but it's not the case. |
Le lundi, 18 mai 2015 à 18:03, Gabriel Radanne a écrit :
What you don't get here is that this is not part of the standard. |
Basically I would be much more clean to have the Uri.(with_query u (Query.of_kvs kvs))
Uri.(Query.to_kvs (query u)) In this world there is no confusing priming/multiplication of entry points for URI components and we make a good distinction between what the standard is and how you can use it – for example the standard is absolutely not this which is confusing. As a standard implementer it is also your duty to provide a good conceptual model and understanding of the standard through the API you provide. |
sight Yes, I get it, and I don't care, because ocaml-uri already does a bit more than the standard and that it's more convenient to the user this way. @rgrinberg asked my opinion, I gave it. The most structured output first, the raw stuff in an auxiliary function, not the other way around. Using uri for now is annoying both because it's inconsistent and because it doesn't always give you the most structured representation (heh, path as raw string). Outputing something very raw just to restructure it after while it's already structured inside Uri.t just sucks. |
And annoying if that's not your use case, see #57. And frankly the fix, a If you are reading code and a have a clear understanding of what an uri and its component are you can only wonder at what all these crap names are about. Concerns should be clearly separated with a good base
Well the fact that it's apparently structured inside |
Having the names of the standard map to what they can actually represent is also much more useful for guiding people who didn't read the RFC or haven't a clear understanding of what an uri is. By not misleading them with wrong representation you minimize the chances that they do wrong assumptions about the way uris are supposed to be processed in general, which leads to better software in the end. |
I agree with @dbuenzli on principle about having Even a hypothetical |
Nothing wrong but the answers can be quite different, name wise. So what's the difference syntactically on an example I don't understand your wording ("key value pairs vs. key list value pairs") ? |
I've explained in my first comment so that was just an attempt to wordit concisely: Context: primed functions handle the query string as a For example: val with_query : t -> (string * string list) list -> t
val with_query' : t -> (string * string) list -> t In a hypothetical query module you could imagine it being module Query : sig
val update : t -> (string * string list) list -> t
val update' : t -> (string * string) -> t
end |
Precisely I don't understand what this represents, how do you translate that to a query string ? |
We can ask Uri: # Uri.encoded_of_query ["foo",["bar";"baz"];"ocaml",["uri"]];;
- : bytes = "foo=bar,baz&ocaml=uri" |
Is this standardized or just something that often happens ? First gut reaction is that t -> (string * string list) list -> t should be at least ?sep:string -> t -> (string * string list) list -> t |
Something around multivalued comes to mind. Tentative: Query.of_fields : (string * string) list -> string
Query.of_multi_fields : ?sep:string -> (string * string list) list -> string |
If deemed too long |
http://www.w3.org/TR/html5/forms.html, grep |
Excellent thanks ! This is precisely "When the multiple attribute is specified on the element", hence I think the multivalued idea is definitively on the right track. W.r.t. to the |
Ah but wait. You would certainly like to this on a per field basis. This suggests that maybe having |
functions with primes shouldn't have, functions without should; get_query_param* is the current exception
The text was updated successfully, but these errors were encountered: