Zulip Chat Archive
Stream: new members
Topic: Default argument depending on type
Josh Cohen (Sep 16 2025 at 14:39):
I am trying to define something like the following:
inductive Foo (T : Type := Unit) : Type where
| A
| B (t : T) (f: Foo T)
I would like the t argument to Bto be automatically populated with () whenever T is Unit (or even just in the default case). Is this possible?
Kenny Lau (Sep 16 2025 at 15:02):
inductive Foo (T : Type := Unit) : Type where
| A
| B (t : T := by exact ()) (f: Foo T)
Robin Arnez (Sep 16 2025 at 15:10):
Just to note though: Default arguments before mandatory arguments don't make much sense (unless you're willing to write (Foo.B) .A)
Josh Cohen (Sep 16 2025 at 15:25):
Thanks, yes I figured out that I needed to move the default argument to the end
Last updated: Dec 20 2025 at 21:32 UTC