Proposal: have "container" types override the `valueOf` method
See original GitHub issueI’m still digesting the changes in ap
, and reading again the discussions in #50 and #144, and there’s a thing that bothers me.
With the current specifications we have to access the value contained in another Apply
directly and that feels very wrong (example here).
What about having all “container” types override the inherited Object.prototype.valueOf to get the contained value?
Should be useful in more cases, and for more reasons, than the ap
one I’m mentioning now.
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (8 by maintainers)
Top Results From Across the Web
Type Parameters Proposal
The only operations that can be done with a value of interface type, other than operations permitted for any type, are to call...
Read more >java - (Error: valueOf(Class<T>, String) of type Enum<E> but ...
The problem is that static <T extends Enum<T>> T Enum.valueOf(Class<T> enumType, String name) is not the same as your public static TestEnum ...
Read more >Built-in Types — Python 3.11.1 documentation
Python supports a concept of iteration over containers. This is implemented using two distinct methods; these are used to allow user-defined classes to ......
Read more >Part 48 - Value Engineering | Acquisition.GOV
48.103 Processing value engineering change proposals. ... are granted on a case-by-case basis, or for specific classes of contracts, ...
Read more >Share Compose configurations between files and projects
Compose supports two methods of sharing common configuration: ... This is required because override files need not be valid Compose files.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What makes it feel wrong to you?
The author of a data type knows how to access its private fields. Accessing the private
value
field ofb
is no different from accessing the privatevalue
field ofthis
innew Id(b.value(this.value))
.👎 for doing anything with
valueOf
. It isn’t necessary, and the thought of specifying a method primarily used for type coercion is concerning. Furthermore it would be tragic to see people useMaybe#valueOf
rather than safely unwrap a value with a function such asfromMaybe
.@ascartabelli to “extract” contained value you can define
extract
method fromComonad
, but not every type is comonad and not every instance of type holds value (List.Nil, Tree.Leaf).Basically we already have a method for
extract
ing value from container, so i think this should be closed if there are no more things to discuss.