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

feat: add isEmptyArray #288

Merged
merged 3 commits into from
Jan 19, 2018
Merged

Conversation

guillaumearm
Copy link
Collaborator

Ref #279

@guillaumearm
Copy link
Collaborator Author

@char0n : any suggestions ?

@char0n
Copy link
Owner

char0n commented Jan 17, 2018

Will get to this in a couple of hours. Thanks

Copy link
Owner

@char0n char0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean and nice. Couple of issue need to be addressed before merging. Nice job!

/**
* Checks if input value is an empty `Array`.
*/
isEmptyArray(val: any): val is Array<any>;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BjornMelgaard I'm not sure about this. Can you advice ? Does this signature make sense in the context of empty array ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as here #289 (comment)

@@ -0,0 +1,21 @@
import * as RA from '../src/index';
import eq from './shared/eq';

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add one more new line pls

* RA.isEmptyArray(42); // => false
* RA.isEmptyArray('42'); // => false
*/
const isEmptyArray = both(isEmpty, isArray);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd go for a following composition. It may same same computing time. Checking if something is array is simpler then checking if an value is empty.

const isEmptyArray = both(isArray, isEmpty);

* @func isEmptyArray
* @memberOf RA
* @since {@link https://char0n.github.io/ramda-adjunct/2.4.0|v2.4.0}
* @category Type
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking if this still falls into Type category or is already an Logic. @guillaumearm what's your opinion on this ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be using logic under the hood, but its API and usage put it in Type imho.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, it's a mix of both : Type and Logic

Because an empty array and a non empty array have the same type, it's a very good question to ask.
Is it ok to passing same type to a Type function produce a different result ?

on another side RA.isNotEmpty should be in Logic category like R.isEmpty

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for creating the issue for it. I’ll handle that. Regarding the question whether this is type or logic... I would say we are still in type world. If we look at it throug the lens of category theory let us say we have two new types EmptyArray and NonEmptyArray. Assuming this we cas say that our two new type functions are just checking out the correct types. Logic of the checking becomes only the implementation detail.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems correct, Agree ^^

@char0n
Copy link
Owner

char0n commented Jan 18, 2018

Pls rebase this pr on top of current master also

@guillaumearm
Copy link
Collaborator Author

Should I --amend my feat commit ?

@char0n
Copy link
Owner

char0n commented Jan 18, 2018

No need to, you have to rebase your branch guillaumearm:feat/isEmptyArray on top of char0n:master and resolve conflicts. I you don't know how to do that, push one additional commit that deals with the PR review comments and I'll deal with conflicts.

@guillaumearm
Copy link
Collaborator Author

No no i'm ok with that ;-) thanks

Guillaume ARM added 2 commits January 18, 2018 16:38
according to char0n#279, checking if something is array is simpler then checking if an value is empty.
@char0n char0n merged commit 961692e into char0n:master Jan 19, 2018
@guillaumearm guillaumearm deleted the feat/isEmptyArray branch January 19, 2018 19:42
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

Successfully merging this pull request may close these issues.

4 participants