Inspired by this Stack Overflow post: https://stackoverflow.com/questions/49508509/idiom-to-construct-a-uri-with-a-query-string-in-elixir/72223901
I thought it might be useful to have helpers to update the struct fields, rather than manipulating the struct directly. Instead of: %URI{uri | host: "example.com"} Map.put(uri, :host, "example.com") etc. We could do: URI.put_host(uri, "example.com") I was thinking that one helper per struct field would be useful. Or maybe only adding a helper for query: `put_query/1` would be an option. Query seems useful, as there is currently no way to programmatically construct a URI with a safely-encoded query string using the `URI` module without manually updating the `query` property (or manually appending the query to a string and calling URI.new again). In the case of `put_query`, it could have two versions: one that puts a string, and one that accepts an enumerable and wraps up encode_query/2. URI.new!("https://example.com") |> URI.put_query(foo: "bar", baz: "qux") Come to think of it, accepting a query enumerable to `new` might even be worth it. I realise this is just syntax sugar, so there might not be desire for such a feature, hence this post. :) -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/666650f2-7a75-4784-b79e-883bff6a3eb8n%40googlegroups.com.