Zulip Chat Archive

Stream: new members

Topic: error msg in for loop


Alok Singh (Jan 08 2024 at 09:28):

def Array.min [LT a](self: Array a) := Id.run do
  let mut min? := none
  for x in self do
    if let some y := min? then
      if x < y then
        min? := x

gives error msg failed to synthesize instance Decidable (x < y).

Kevin Buzzard (Jan 08 2024 at 09:54):

That looks expected to me -- if you want to use if then you need an algorithm.

Damiano Testa (Jan 08 2024 at 10:31):

... and you can fix it by adding [DecidableRel ((· < ·) : a → a → Prop)] to your assumptions.


Last updated: May 02 2025 at 03:31 UTC