Closed martinlechner1 closed 7 years ago
This function does not actually take a value of type Nullable a
as an argument, since it also treats undefined
specially. It's misleading to use nullable in this function's name. I suggest toMaybe
, to match S.toMaybe
.
I've been using a?
to represent the type whose members are null
and undefined
in addition to all the members of a
.
Thanks for the input. I will change the code accordingly.
On Tue, Nov 8, 2016, 11:57 David Chambers notifications@github.com wrote:
This function does not actually take a value of type Nullable a https://github.com/sanctuary-js/sanctuary-def#nullable as an argument, since it also treats undefined specially. It's misleading to use nullable in this function's name. I suggest toMaybe, to match S.toMaybe https://sanctuary.js.org/#toMaybe.
I've been using a? to represent the type whose members are null and undefined in addition to all the members of a.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ramda/ramda-fantasy/pull/133#issuecomment-259107207, or mute the thread https://github.com/notifications/unsubscribe-auth/AGXLaZ6RT8oA2fobkRLWtx6uO9Yn9F7Oks5q8FWYgaJpZM4KruON .
The changes look good. Could you update the pull request's title accordingly?
This is essentially an alias of the constructor. What about ramdas no alias policy?
The primary motivation was to not use the constructor directly to have a cleaner general code style while using the lib. See: http://eslint.org/docs/rules/new-cap Having Maybe.toMaybe(value) is in my opinion superior to Maybe(value), since you express your intent more cleanly.
I disagree with the claim that toMaybe
is more clear. That name does not reveal anything except that it returns a Maybe.
Regarding the rule, I have been forced to deactivate it on some projects since there are functions that are not constructors but that do start with a capital letter such as the I
, K
combinators.
One more reason I don't like the single-letter combinator names! :smile:
One more reason I don't like the single-letter combinator names!
Haha to each his own but I prefer eslint to be a helper and not rule my world =)
No, I turn off linting rules all the time. I've enforced similar rules in JS codebases long before I had linters available; it has seemed a good convention for JS.
My main objection to the single-letter names is how nondescriptive they are. I have the same problem using bird names. I like for me and others to be able to read the code!
What about the merge request? There is another not mentioned benefit. The classic constructor does not handle the undefined case (which I would like to have handled too).
The classic constructor does not handle the undefined case
yes it does. x == null
equals true for undefined
and null
Closing as implemented via #159.
As discussed in Issue #132, I added a proposal for a ofNullable static constructor.