Zulip Chat Archive
Stream: metaprogramming / tactics
Topic: Lift from Option to MetaM
Heather Macbeth (Nov 03 2024 at 01:05):
There is a lift from Option to MetaM implemented in the norm_num
code, apparently dating from #519 (@Mario Carneiro).
I want this elsewhere, so I was thinking of moving it to a standalone file in Mathlib.Util
. Does this sound ok?
Is there any part of mathlib where this shouldn't be imported? By the way, Lake.Util.Lift
apparently contains a MonadLiftT
for this: docs#Lake.instMonadLiftTOptionOfAlternative_lake.
Kyle Miller (Nov 03 2024 at 01:09):
There's at least docs#Option.toMonad and docs#Option.getDM for turning Option into a monadic value
Kyle Miller (Nov 03 2024 at 01:10):
I often also write things like let some x := v? | failure
Heather Macbeth (Nov 03 2024 at 01:10):
OK, would it be better to delete the lift instance in the norm_num
code and use one of those idioms instead?
Eric Wieser (Nov 03 2024 at 01:42):
Is using docs#OptionT another helpful approach here?
Heather Macbeth (Nov 03 2024 at 01:44):
Kyle's suggestions are fine for my purposes, now I'm just wondering about cleanup elsewhere.
Damiano Testa (Nov 03 2024 at 08:20):
I have a memory of some very confusing behaviour with the lift instance mentioned above. Let me see if I can find the relevant thread.
Damiano Testa (Nov 03 2024 at 08:54):
I think that these were the threads that I had in mind:
Heather Macbeth (Nov 03 2024 at 16:32):
It seems not very user-friendly to have the presence/absence of the norm_num
import determine whether this lift is present or not: this is an unpredictable criterion. Maybe the instance in the norm_num
file should be downgraded to a local instance?
Kyle Miller (Nov 03 2024 at 16:36):
Yes, that seems like a good idea to make it local (or to eliminate it)
Heather Macbeth (Nov 05 2024 at 23:09):
Yaël Dillies (Nov 09 2024 at 08:43):
Oooh, that's why I got errors in my positivity extensions when bumping. What's the preferred fix? Adding the instance locally? Using the let some x := v? | failure
idiom?
Yaël Dillies (Nov 09 2024 at 08:48):
I've added the instance locally, but I'm happy to switch to something else
Kyle Miller (Nov 09 2024 at 16:31):
It depends on specifics, but let some x := v? | failure
(or throwError
instead of failure
) is a reasonable choice I think.
Yaël Dillies (Nov 09 2024 at 19:40):
I got a weird error doing that, because my v?
contains some ←
themselves
Yaël Dillies (Nov 09 2024 at 20:46):
Turns out I had simply forgotten the trailing | failure
Last updated: May 02 2025 at 03:31 UTC