Zulip Chat Archive
Stream: new members
Topic: Idiomatic way to error out if a value is not none
Vlad Tsyrklevich (Feb 15 2025 at 11:16):
I want to verify that a function returns none in some meta-code, I am currently doing
let none := (← get).env.constants.find? name | elabTheorem stx
which seems better than
if (← get).env.constants.contains name then
elabTheorem stx
return
but let none :=
seems a bit odd to me, is there a more idiomatic way to do this?
Aaron Liu (Feb 15 2025 at 17:03):
Maybe docs#guard with docs#Option.isNone
Eric Wieser (Feb 15 2025 at 17:09):
if let some existing := ... then return ...
is another option
Last updated: May 02 2025 at 03:31 UTC