typelevel / typelevel/cats

Type class instances for isomorphic types

Open
#1,610 5 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
5.5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
5

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Gitter conversation and related issue #992 to understand the proposed isomorphism API and unresolved design questions. Define what a delegated type class instance should expose and how the bidirectional transformations are supplied; done means a workable design with coverage for the DecodeJson/Kleisli example.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.