Skip to content

Implement Predicate combinators #98 #102

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

Closed
wants to merge 0 commits into from

Conversation

amarpotghan
Copy link
Contributor

No description provided.

@amarpotghan
Copy link
Contributor Author

@mperry can you please have a look? please provide feedback.

@mperry
Copy link
Contributor

mperry commented Feb 4, 2015

On my list of todos.

@amarpotghan
Copy link
Contributor Author

:) thanks

public static <A, B> F<B, Boolean> contramap(F<B, A> f, F<A, Boolean> p){
return compose(p, f);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this mapping over a function, rather than a contramap? E.g. F1W.lift(...).map(....)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

technically it's a contramap, because it's applying function to input of F&lt;A, Bool&gt; (negative position)

Copy link
Contributor

Choose a reason for hiding this comment

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

I see now, it is contramapping over the predicate, whereas I was thinking it was mapping over the first function. It looks like these two cases are equivalent here, but given we are focused on predicates contramap is appropriate for the name.

@mperry
Copy link
Contributor

mperry commented Feb 7, 2015

In summary, need to resolve contramap. Thanks for this PR and pushing FunctionalJava forward, it is great to see. In future, do work on a branch (not master) and submit a PR. We don't need the extra noise of additional commits in the PR that I believe is caused by working on master.

@mperry mperry added this to the v4.3 milestone Feb 7, 2015
@amarpotghan
Copy link
Contributor Author

@mperry thanks, you will see changes in a branch henceforth.

@tonymorris
Copy link
Contributor

I think the names are fine as is. Specifically, I think contramap is appropriately named.

Here are some considerations:

  • Rename isnot to simply not. I only make this suggestion because it has some precedence, at least in my experience.
  • If you leave isnot named as-is, consider adding another method is, which is simply an alias for contramap. Give the users a choice between a preferred name, if it happens to be that way.

In some older Haskell libraries, with use of contravariant functors, the name comap was used (where contramap is used here). This is an inappropriate name, since the prefix co has a strong precedence to mean categorical duality, where no such duality has existed. Since this time, the name contramap has been used as the correction and I have never seen any more appropriate name.

Unlike for invariant (exponential) mapping, where I have seen several different names, for the same type of mapping; xmap, expmap, invmap.

@mperry
Copy link
Contributor

mperry commented Feb 7, 2015

Data.Function.Predicate (http://hackage.haskell.org/package/predicates-0.1/docs/Data-Function-Predicate.html) uses is and isn't, so I suggest we add is as an alias to contramap.

@mperry
Copy link
Contributor

mperry commented Feb 9, 2015

Hi @amarpotghan, why did you close this PR?

@amarpotghan
Copy link
Contributor Author

@mperry created pull-request #104 to remove commit noise :)

@mperry mperry removed the enhancement label Feb 9, 2015
@mperry mperry removed this from the v4.3 milestone Feb 9, 2015
@mperry mperry added the invalid label May 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants