Skip to content

Implement Zipper Eq and Hash and add tests#343

Merged
jbgi merged 1 commit into
functionaljava:masterfrom
gliptak:coverage6
Aug 2, 2018
Merged

Implement Zipper Eq and Hash and add tests#343
jbgi merged 1 commit into
functionaljava:masterfrom
gliptak:coverage6

Conversation

@gliptak

@gliptak gliptak commented Jul 29, 2018

Copy link
Copy Markdown
Contributor

Signed-off-by: Gábor Lipták gliptak@gmail.com

@codecov-io

codecov-io commented Jul 29, 2018

Copy link
Copy Markdown

Codecov Report

Merging #343 into master will decrease coverage by 0.54%.
The diff coverage is 20%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #343      +/-   ##
==========================================
- Coverage   41.49%   40.95%   -0.55%     
==========================================
  Files         176      176              
  Lines        9174     9189      +15     
  Branches      522      524       +2     
==========================================
- Hits         3807     3763      -44     
- Misses       5217     5264      +47     
- Partials      150      162      +12
Impacted Files Coverage Δ
core/src/main/java/fj/Hash.java 20.71% <0%> (-1.26%) ⬇️
core/src/main/java/fj/Equal.java 48.02% <40%> (-0.24%) ⬇️
core/src/main/java/fj/data/Zipper.java 31.57% <50%> (+31.57%) ⬆️
core/src/main/java/fj/F7Functions.java 0% <0%> (-100%) ⬇️
core/src/main/java/fj/F3Functions.java 0% <0%> (-100%) ⬇️
core/src/main/java/fj/Digit.java 0% <0%> (-100%) ⬇️
core/src/main/java/fj/F6Functions.java 0% <0%> (-100%) ⬇️
core/src/main/java/fj/F8Functions.java 0% <0%> (-100%) ⬇️
core/src/main/java/fj/F5Functions.java 0% <0%> (-100%) ⬇️
core/src/main/java/fj/F4Functions.java 0% <0%> (-100%) ⬇️
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1849e1d...ae70d20. Read the comment docs.

Comment thread core/src/main/java/fj/Equal.java Outdated
Zipper<A> x1 = a1;
Zipper<A> x2 = a2;

x1.move(0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

those two move(0) statements do nothing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The zipper handed out might not be focus at start. Let me know if you think they are not needed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

but move is a pure function so you must use the result if you want to do that.
But probably the position of a zipper is important and I'd be in favor of just comparing lefts(), focus() and right(). This is also what the haskell implementations I have seen do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks for the pointer. updated

Comment thread core/src/main/java/fj/Hash.java Outdated
int r = 239;
Zipper<A> aas = as;

aas.move(0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this does nothing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The zipper handed out might not be focus at start. Let me know if you think they are not needed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same as for Equal, I'd say we just need to combine the hash of lefts(), focus() and right().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated

Comment thread core/src/main/java/fj/Equal.java Outdated
public static <A> Equal<Zipper<A>> zipperEqual(final Equal<A> ea) {
Definition<A> eaDef = ea.def;
return equalDef((a1, a2) -> {
return Equal.equals0(Stream.class, a1.lefts(), a2.lefts(), () -> Equal.streamEqual(Equal.anyEqual())) &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think streamEqual should use Equal<A> not anyEqual. also It would be best to save the streamEqual in a local variable for reuse.
Also equals0need to be used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

partially updated. I'm not sure about equals0

Comment thread core/src/main/java/fj/Hash.java Outdated
final int p = 419;
int r = 239;

r = p * r + streamHash(ha).hash(as.lefts());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

also probably best to save streamHash(ha) in a local variable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@jbgi

jbgi commented Aug 1, 2018

Copy link
Copy Markdown
Member

@gliptak added a commit with remaining observations: aa295b9
Please squash it/fixup and I will merge.

Signed-off-by: Gábor Lipták <gliptak@gmail.com>
@gliptak

gliptak commented Aug 1, 2018

Copy link
Copy Markdown
Contributor Author

thank you for the update. squashed.

@jbgi
jbgi merged commit 3777c1f into functionaljava:master Aug 2, 2018
@jbgi jbgi added this to the 4.8 milestone Aug 18, 2018
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.

3 participants