Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Add an ApplyK type class? #38

Closed
LukaJCB opened this issue Jul 4, 2018 · 8 comments · Fixed by #40
Closed

Add an ApplyK type class? #38

LukaJCB opened this issue Jul 4, 2018 · 8 comments · Fixed by #40

Comments

@LukaJCB
Copy link
Contributor

LukaJCB commented Jul 4, 2018

I'd love to see a very simple ApplyK typeclass that'd let us use something like this:

def map2K[F[_], G[_], H[_]](af: A[F], ag: A[G])(f: Tuple2K[F, G, ?] ~> H): A[H]

And it should also be able to be derived fairly easily, right?

@kailuowang
Copy link
Owner

kailuowang commented Jul 5, 2018

Is this also isomorphic to CartesianK (or SemigroupalK) + FunctorK ?

@LukaJCB
Copy link
Contributor Author

LukaJCB commented Jul 5, 2018

Yes exactly :)

@kailuowang
Copy link
Owner

so we have at least 3 options to provide derivation here.
Option 1, in ApplyK companion, we provide a method that derives an instance from FunctorK and SemigroupalK instances. Then users have to add both @autoFunctorK and @autoSemigroupalK to their algebra.
Option 2, we provide a new @autoApplyK annotation and reuse the code from the @autoFunctorK and @autoSemigroupalK.

WDYT?

@LukaJCB
Copy link
Contributor Author

LukaJCB commented Jul 5, 2018

I think I prefer Option 2, seems more consistent and also more convenient for the end user. I'd gladly contribute the typeclass + laws + docs, but I'm not sure if I can help with the macros. If you want I could create a PR that adds those things :)

@kailuowang
Copy link
Owner

@LukaJCB, it would be awesome if you could add the typeclass + laws + docs.
Actually, if you want you could even add the derivation method in the companion mentioned in Option 1 (should be just a couple of lines of code I think) so that you can start using it while waiting on the @autoApplyK macro.

@LukaJCB
Copy link
Contributor Author

LukaJCB commented Jul 5, 2018

Will do, thanks! :)

@LukaJCB
Copy link
Contributor Author

LukaJCB commented Jul 5, 2018

Btw for a use case, you can look here :) typelevel/typelevel.github.com#220

@kailuowang
Copy link
Owner

Noice, another awesome one from you.

@LukaJCB LukaJCB mentioned this issue Jul 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants