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

InvariantMonoidal + FreeInvariant? #802

Closed
OlivierBlanvillain opened this issue Jan 14, 2016 · 6 comments
Closed

InvariantMonoidal + FreeInvariant? #802

OlivierBlanvillain opened this issue Jan 14, 2016 · 6 comments

Comments

@OlivierBlanvillain
Copy link
Contributor

Would you be interested in a new type class:

@typeclass trait InvariantMonoidal[F[_]] extends Invariant[F] with Monoidal[F]

And a new Free structure for it? Something along the lines of the stuff we built with
@Fristi, https://gist.github.com/OlivierBlanvillain/b6322caec0318734c12b

I think this is what would be needed in a PR, let me know if I forgot something:

  • cats.InvariantMonoidal
  • cats.laws.InvariantMonoidalLaws
  • cats.free.FreeInvariant
  • cats.tests.FreeInvariantTests
  • tut.freeinvariant.md

With s/Monoidal/Cartesian/ after #795 :)

@Fristi
Copy link
Contributor

Fristi commented Jan 14, 2016

👍 I would be keen to help out here.

Very useful stuff, for me atleast.

Here's my version: https://gist.github.com/Fristi/5d8efe3eeddff88a6fc4

It's a prototype for a bidirectional router. Route parts are translated to either documentation or codecs by using this Free version (also been thinking about creating a JSON algebra in Free InvariantCartesian form, so you would be able to derive JSON schema and codecs from it, but haven't tried that out.). I couldn't make this work with Free applicatives, since a Applicative needs a Functor implementation, and I can't make that for codec.

I wonder what other Free variants there are. You can combine several typeclasses and lift their operations in a Free variant. But what combinations would work and be useful? Also a thing about naming these; What if I would something like Invariant + Monoidal + SemigroupK, would you name it FreeInvariantMonoidalSemigroupK? Sounds abit like stacking OO design patterns to me. Is there any work done on naming these combinations of typeclasses elsewhere (haskell, category theory)?

@OlivierBlanvillain
Copy link
Contributor Author

@mpilquist What's your opinion on that?

All credits goes to you for coming with the name in your SBTB talk :)

@mpilquist
Copy link
Member

👍 This looks good to me!

@ceedubs
Copy link
Contributor

ceedubs commented May 19, 2016

Sorry for not responding for so long but I started pondering a project today that I think could really benefit from this. Now that free has its own module again, I'm less concerned about adding more structures to it. 👍 from me.

@ceedubs
Copy link
Contributor

ceedubs commented May 19, 2016

Uh ignore my last comment. I had forgotten there is an open PR for this.

@peterneyens
Copy link
Collaborator

Added in #845.

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

5 participants