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

summon ApplicativeErrorSyntax for F[_] instead of F[_, _] #1046

Merged
merged 2 commits into from
May 20, 2016

Conversation

kailuowang
Copy link
Contributor

No description provided.

implicit def applicativeErrorIdSyntax[E](e: E): ApplicativeErrorIdOps[E] =
new ApplicativeErrorIdOps(e)

implicit def applicativeErrorSyntax[F[_, _], E, A](fa: F[E, A])(implicit F: ApplicativeError[F[E, ?], E]): ApplicativeErrorOps[F[E, ?], E, A] =
implicit def applicativeErrorSyntax2[F[_, _], E, A](fa: F[E, A])(implicit F: ApplicativeError[F[E, ?], E]): ApplicativeErrorOps[F[E, ?], E, A] =
Copy link
Contributor

Choose a reason for hiding this comment

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

I’d rather replace this one with a variant using Unapply.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To me Unapply is hard to read, I thought this variant does the same thing, so if you don't mind, could you educate what's the benefit of using Unapply over this variant?

Copy link
Contributor

@julienrf julienrf May 17, 2016

Choose a reason for hiding this comment

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

Unapply is a more general solution to the type inference problem that you are currently solving with this PR. But it will (hopefull soon!) become useless because SI-2712 is going to be fixed.

Once this will be the case, projects like cats will follow some migration path to get rid of the current workarounds. One possible migration path could be to move every Unapply-related methods to an external project that could be kept maintained just for compatibility with old Scala versions.

So, using Unapply clearly marks that the implicit definition will be useless once SI-2712 is fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@julienrf, being consistent is a good point although I would imagine you want to cross build this code, meaning, I am not sure you can to simply remove the Unapply usage in the code base.
@ceedubs mentioned in the chatroom that we don't want to over invest in Unapply post the SI-2712 fix. That being said, I am totally willing to turn this into Unapply, if that's the consensus.
Maintainers any thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am hopeful that Unapply's days are numbered. However, if we are going to add this sort of thing to help with inference (which is probably its own question now that the SI-2712 fix plugin exists), I think that we should reuse Unapply instead of less general workarounds like this one. Having said that, I briefly tried hooking up Unapply to this and was having trouble getting the syntax to be recognized for Xor - maybe someone else can do a better job than I did?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ceedubs do we want to do the originally proposed change, which is, just change it to F[_]?

Copy link
Contributor

Choose a reason for hiding this comment

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

@kailuowang yeah, that sounds reasonable to me. Have you by any chance checked that works when using the SI-2712 fix?

@travisbrown do you have any strong opinions on this? I think you originally added the applicative error syntax.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just checked with the SI-2712 fix, it works fine (can find syntax for F[_, _] with only one F[_] variant.
Removing the existing F[_, _] variant, however, would mean we need to change existing syntax tests to use Option instead of Xor, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, or introduce a type alias.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

per @travisbrown at gitter chat, I am going to replace the F[_, _] with F[_] and change tests to use Option

@codecov-io
Copy link

codecov-io commented May 17, 2016

Current coverage is 88.57%

Merging #1046 into master will increase coverage by <.01%

@@             master      #1046   diff @@
==========================================
  Files           214        214          
  Lines          2719       2720     +1   
  Methods        2655       2656     +1   
  Messages          0          0          
  Branches         59         59          
==========================================
+ Hits           2407       2409     +2   
+ Misses          312        311     -1   
  Partials          0          0          

Powered by Codecov. Last updated by 271c197...642d1fe

@kailuowang kailuowang changed the title added support for summon ApplicativeErrorSyntax for F[_] summon ApplicativeErrorSyntax for F[_] instead of F[_, _] May 19, 2016
@travisbrown
Copy link
Contributor

I don't have a strong opinion here, and I've never used the ApplicativeError syntax (it looks like it was introduced by @davegurnell, so ideally I guess we'd want to get him to sign off on this change), but off-hand I prefer the F[_] version.

@non
Copy link
Contributor

non commented May 19, 2016

Seems reasonable to me. 👍

@ceedubs
Copy link
Contributor

ceedubs commented May 19, 2016

👍

@philwills
Copy link
Contributor

Thanks @kailuowang, I think this could be really useful.

@non non merged commit 207fda4 into typelevel:master May 20, 2016
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.

7 participants