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

Type class instances for isomorphic types #1610

Open
ceedubs opened this issue Apr 18, 2017 · 5 comments
Open

Type class instances for isomorphic types #1610

ceedubs opened this issue Apr 18, 2017 · 5 comments

Comments

@ceedubs
Copy link
Contributor

ceedubs commented Apr 18, 2017

Related Gitter conversation: https://gitter.im/typelevel/cats?at=58f5f7e801d449152eb5c5dc

It may be nice to provide an easy way to create type class instances that simply delegate to the type class instances of an isomorphic type. For example, if I create final case class DecodeJson[A](decode: Kleisli[Either[String, ?], Json, A]), then I can easily create an iso functor (a bidirectional tranformation via a pair of DecodeJson ~> Kleisli[Either[String, ?], Json, ?] and Kleisli[Either[String, ?], Json, ?] ~> DecodeJson). It seems like I should be able to pass in this iso functor to create a Monad[DecodeJson] that simply delegates through to the Kleisli Monad and runs the transformations on both ends.

I mentioned this use-case as motivation for #992, but that ticket seems to be stalled, and I'm not sure whether we'll go through with it. I think that this functionality could be useful whether or not anything happens with #992.

@kailuowang
Copy link
Contributor

kailuowang commented Apr 18, 2017

👍 The isomorphism defined in scalaz is meticulous. It defines multiple isomorphisms with different kinds

@qingwei91
Copy link

Hi ~ is this feature still desirable?
If so, is it currently being work on?

I am happy to help

@ceedubs
Copy link
Contributor Author

ceedubs commented Dec 16, 2018

I think that this is still desired, but there are a number of design decisions that would need to be made, such as whether these isomorphism instances are auto-generated by the build. It might make sense to start this out as an experimental module (or even a separate repo) before we consider it to be part of Cats proper.

@qingwei91
Copy link

qingwei91 commented Dec 17, 2018

@ceedubs Cool, is there a discussion somewhere around these design consideration?

I'll give it a go if nobody is working on it in a separate repo, do you think following what scalaz did is a good start?

Cheers

@kailuowang
Copy link
Contributor

👍 on an experiment module and following what scalaz did.

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

No branches or pull requests

3 participants