Zulip Chat Archive

Stream: lean4

Topic: generic constraints


J. O. (Feb 04 2022 at 02:25):

I have two parameters which are generic, but they need to both have a ToString instance. is there any way to put a constraint for the generic type, so that the type can only be one that has a ToString instance? thanks in advance

Mario Carneiro (Feb 04 2022 at 02:31):

example (A : Type) [ToString A] : ...

J. O. (Feb 04 2022 at 02:33):

that works. thanks! what type of argument is that again. time to look at the manual

Johan Commelin (Feb 04 2022 at 02:35):

"instance implicit"

J. O. (Feb 04 2022 at 02:35):

ah yes


Last updated: Dec 20 2023 at 11:08 UTC