Zulip Chat Archive

Stream: new members

Topic: Canonical Trivial Typeclass?


Oskar Goldhahn (May 19 2023 at 13:40):

I'm writing something that is generic over typeclasses. Is there a Canonical Trivial Typeclass that I can use as the default? Something like: class Any (_: Type u)?

Eric Wieser (May 19 2023 at 13:50):

Generalizing over type classes doesn't really work very well in lean; is this perhaps an #xy problem?

Oskar Goldhahn (May 19 2023 at 13:52):

It's for #Is there code for X? > Restricted Monads.

Oskar Goldhahn (May 19 2023 at 13:53):

In what way does generalizing over type classes not work well?

Eric Wieser (May 19 2023 at 14:10):

Well, your generalization won't work for docs#star_ring for instance

Eric Wieser (May 19 2023 at 14:11):

Because it has too many arguments

Oskar Goldhahn (May 19 2023 at 14:15):

I'm fine with requiring a shim that uncurries the typeclasses.

Eric Wieser (May 19 2023 at 14:36):

At that point you could consider uncurrying the typeclasses elsewhere too, and bundle them in the types themselves

Eric Wieser (May 19 2023 at 14:36):

That's what things like docs#Group are

Oskar Goldhahn (May 19 2023 at 15:00):

I see. I can give that a try.

Eric Wieser (May 19 2023 at 15:21):

That pretty much amounts to what Scott suggested in the other thread, of course...


Last updated: Dec 20 2023 at 11:08 UTC