Zulip Chat Archive

Stream: general

Topic: Allow inferring constructor for Sum


nrs (Oct 16 2024 at 08:22):

Is there any practical way to have the following typecheck?

example : List (Sum Int (List Int)) := [7, 9, [10, 1]]

Instead of having to write

example : List (Sum Int (List Int)) := [.inl 7, .inl 9, .inr [10, 1]]

nrs (Oct 16 2024 at 08:58):

solved: you can achieve this with coercions. See https://lean-lang.org/functional_programming_in_lean/type-classes/coercion.html

Eric Wieser (Oct 16 2024 at 09:35):

Note that this is arguably a bad idea, because what would 1 : Sum Int Int mean?


Last updated: May 02 2025 at 03:31 UTC