question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: have "container" types override the `valueOf` method

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
davidchamberscommented, Nov 29, 2016

With the current specifications we have to access the value contained in another Apply directly and that feels very wrong

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 of b is no different from accessing the private value field of this in new 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 use Maybe#valueOf rather than safely unwrap a value with a function such as fromMaybe.

1reaction
safarelicommented, Dec 8, 2016

My point about interoperability, as I previously said, still stands though as another function could be used for the same purpose.

@ascartabelli to “extract” contained value you can define extract method from Comonad, 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 extracting value from container, so i think this should be closed if there are no more things to discuss.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found