Skip to content

Representable instance for Cofree#3858

Open
TimWSpence wants to merge 1 commit into
typelevel:mainfrom
TimWSpence:representable-for-cofree
Open

Representable instance for Cofree#3858
TimWSpence wants to merge 1 commit into
typelevel:mainfrom
TimWSpence:representable-for-cofree

Conversation

@TimWSpence

Copy link
Copy Markdown
Member

Thank you for contributing to Cats!

This is a kind reminder to run sbt +prePR and commit the changed files, if any, before submitting.

@larsrh

larsrh commented Apr 25, 2021

Copy link
Copy Markdown
Contributor

Can we add a test for this?

@TimWSpence

Copy link
Copy Markdown
Member Author

Thanks @larsrh! Sorry, I've been meaning to leave a comment on this for ages. I tried to start a discussion on this (https://gitter.im/typelevel/cats-dev?at=607434731f84d71853b1223f) but nobody took the bait 😭

@armanbilge

Copy link
Copy Markdown
Member

Copy-pasta from the linked gitter.

I opened a PR for adding a Representable instance for Cofree - #3858. I’m pretty sure the implementation is sound but laws testing it is an interesting challenge. The issue is that sum types are not representable (as far as I know and it certainly seems intuitively obvious) and neither are trivial product types like Const. But if we have a genuine product type F[A] with a hole of type A then Cofree[F, A] is necessarily infinite so we can’t construct an Eq instance for checking the laws. My only thought is that we construct an Eq instance that evaluates the tree to some fixed depth and asserts that the sub-trees are equal?

I think the instance is still useful because it seems reasonable for an application to generate this infinite tree structure but only index some finite subtree

@armanbilge armanbilge added this to the 2.9.0 milestone Jun 11, 2022
@armanbilge

Copy link
Copy Markdown
Member

@TimWSpence if law-testing this is challenging, can we add some more vanilla tests or property checks instead?

@armanbilge armanbilge modified the milestones: 2.9.0, 2.10.0 Oct 9, 2022
@armanbilge armanbilge modified the milestones: 2.10.0, 2.11.0 Aug 14, 2023
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.

3 participants