-
Notifications
You must be signed in to change notification settings - Fork 36
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
Inspect implementation of %Cldr.LanguageTag{}
is unhelpful and doesn't align with the docs
#234
Comments
I made this change to be consistent with how Does that clear up what you're seeing? |
It seems like an astounding anti-pattern for a number of reasons:
Cldr.Locale.new("en-ES", TestBackend.Cldr)
{:ok, %Cldr.LanguageTag{
backend: TestBackend.Cldr,
canonical_locale_name: "en-ES",
# (lines cut)
script: :Latn,
territory: :ES,
transform: %{},
language_variants: []
}} I hoped that worst case scenario this was a ham-handed way of
Do they really? All of the examples I can find right now have the iex(7)> ~r/(foo|bar)/u
~r/(foo|bar)/u
iex(8)> spawn fn -> 1 end
#PID<0.110.0>
iex(9)> pid(0, 110, 0)
#PID<0.110.0>
iex(10)> MapSet.new([:foo, :bar, :bar])
MapSet.new([:foo, :bar])
iex(11)> MapSet.new([:foo, :bar])
MapSet.new([:foo, :bar])
iex(12)> URI.new!("https://example.com/en/?foo=bar#header")
%URI{
scheme: "https",
userinfo: nil,
host: "example.com",
port: 443,
path: "/en/",
query: "foo=bar",
fragment: "header"
}
iex(13)> Repo.get!(PersonGroup, "b9a57dde-52b9-4e71-b300-98d6433b9a79")
%Foo.Models.PersonGroup{
__meta__: #Ecto.Schema.Metadata<:loaded, "persons_groups">,
id: "b9a57dde-52b9-4e71-b300-98d6433b9a79",
person_id: "85d52529-49af-4662-b432-9eec82254adf",
person: #Ecto.Association.NotLoaded<association :person is not loaded>,
group_id: "9092bad9-f64a-4bd7-951d-6e38fbdbcbea",
group: #Ecto.Association.NotLoaded<association :group is not loaded>,
inserted_at: ~U[2024-03-14 16:57:47.121775Z]
} Yes, I don't see the whole structure of What you did, however, is the equivalent of this: iex(12)> URI.new!("https://example.com/en/?foo=bar#header")
URI.new!("https://example.com/en/?foo=bar#header")
iex(13)> Repo.get!(PersonGroup, "b9a57dde-52b9-4e71-b300-98d6433b9a79")
Repo.get!(PersonGroup, "b9a57dde-52b9-4e71-b300-98d6433b9a79") Which in my opinion is incredibly pointless and unhelpful. Also, please don't get me wrong, it's not like I wasn't aware of the So the answer does clear up what I'm seeing, but makes the intentions before the decision to make it this way even more bizarre. |
MyApp.Cldr.Locale.new!("en-US")
%Cldr.LanguageTag{}
is unhelpful and doesn't align with the docs
I have posted in Elixir Forum on this topic to see what community and Elixir core team views are on this. |
To say you’ve been working with Elixir for a decade but have never seen this pattern is just unbelievable, it’s everywhere. Elixir uses Inspect for Range Decimal inspects to Ecto makes heavy use of Inspect for nearly everything. Changeset, Query, Schema, NotLoaded, and more Absinthe uses Inspect in this way too, heavily(though often with the older Most people don’t want their logs and iex sessions to be 95% full of 3rd party libraries struct guts that they don’t care about. I don’t care about the internals of the Ecto.Query struct most of the time. If I happen to need to see them, then I can always convert to a map. In the case of this library, I agree with @kipcole9 , most people aren’t needing to see the internals of this struct 99% of the time, and so showing it is just unwanted noise. A snippet of code that executes and generates the same struct is incredibly helpful in the event you want to copy paste some other data structure into iex that happens to contain this library's struct, it’s helpful that it just works and doesn’t throw an error. |
I used
ex_cldr
before, which is why I wanted to use it to fetch some information for a number of locales.When I add it to a project (a real one or a repro one), most of the functions I run return
MyApp.Cldr.Locale.new!("en-US")
for whatever reason.I created a repo with the repro. I tried to keep the configuration minimal:
I re-read the installation/configuration docs a couple of times and fiddled with the config and I'm still getting the same results.
Any advice? I assume (hope) this isn't the expected behaviour.
Edit: I updated the issue title to be actionable.
The text was updated successfully, but these errors were encountered: