I'd like to use record update syntax to update a dependently-typed field without also changing the field it depends on. So I'd like to have Idris 2 evaluate the other field, and realize everything is kosher. Is this doable?
Here's a concrete minimal example:
%default total
0 Top : Type
Top = DPair Type (\t => t)
p1 : Top
p1 = MkDPair Bool True
p1' : Top
p1' = { snd $= not } p1
Here, the definition of p1'
doesn't typecheck, because the type of snd
is fst
, not Bool
. But if only Idris would evaluate p1.fst
, it would all work out.
I am guessing the problem is that this is an application of a general record updater function { snd $= not } : Top -> Top
to the argument p1 : Top
, which of course doesn't quite work. So is there a way to instead start from p1
, and change its field values in the context of its other field values?