Zulip Chat Archive

Stream: metaprogramming / tactics

Topic: Idiom to check whether monad runs without error?


Heather Macbeth (Nov 03 2024 at 00:07):

I wrote some code which, in a convoluted way, returns "true" if a certain MetaM call works, and "false" if it throws an error:

try
  let _  [metaprogram]
  pure true
catch _ => pure false

Is there a shorter idiom for this?

Eric Wieser (Nov 03 2024 at 00:13):

There is docs#observing and docs#Lean.observing?

Eric Wieser (Nov 03 2024 at 00:14):

Or maybe docs#succeeds

Heather Macbeth (Nov 03 2024 at 00:23):

Thanks, succeeds is nice!


Last updated: May 02 2025 at 03:31 UTC