Skip to content
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

Define "checked" in Terminology Section #210

Open
EvanBurchard opened this issue Dec 14, 2016 · 5 comments
Open

Define "checked" in Terminology Section #210

EvanBurchard opened this issue Dec 14, 2016 · 5 comments

Comments

@EvanBurchard
Copy link

Example usage:

No parts of f's return value should be checked.

@Avaq
Copy link
Contributor

Avaq commented Dec 14, 2016

Any kind of inspection of the value, for example value != null, value instanceof Type, typeof value, value.hasOwnProperty(...) etc.

@SimonRichardson
Copy link
Member

We should re-iterate what that actually means in the spec. A lot of libraries don't adhere to that part of the spec, so some clarity might be very useful here.

@EvanBurchard
Copy link
Author

@SimonRichardson can you give an example from a library that doesn't conform?

I'm struggling to understand how the prescriptive "Don't use the kinds of things @Avaq pointed out" is more clear than just the signature itself.

map :: Functor f => f a ~> (a -> b) -> f b

I was confused because yeah, it needs a f b, but nothing in the type signature indicates anything in particular about the type of b. Isn't that enough info?

I'm probably wrong on this, but I feel like:

  1. It doesn't add more info than the type signature
  2. It's oddly framed to be prescriptive, rather than describing the already descriptive type signature.
  3. Its prescription is vague (@Avaq's explanation in definition might be aid in clarity if being prescriptive is desirable)
  4. There's no clear contrasting scenarios/prescriptions for when something "should be checked," so the terminology seems lopsided and out of place.

I don't know. I just found it confusing. Maybe it's just me.

@rjmk
Copy link
Contributor

rjmk commented Dec 14, 2016

@EvanBurchard I think it's to avoid implementations like

MyFunctor.prototype.map = f =>
  MyFunctor.of(f(typeof this.value === 'number' ? this.value + 1 : this.value))

(Though in reality things like null checking are more common)

@SimonRichardson
Copy link
Member

Exactly what @rjmk shown, I've seen this in the wild a couple of times (I need to keep a list of this stuff tbh!).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants