Let's suppose that I have some f : A -> B, a : A, b : B. I want new function, that is almost a copy of f, but it should produce b for an argument a.
I was trying something like this.
replace_f : ∀ {A B} (f : A -> B) (a : A) (b : B)
-> (A -> B)
replace_f f a b = \ { a -> b ; attr -> f attr }
But the a in the lambda definition is not the same as a that I am trying to replace.
Agda just considers it as a variable.
P. S.
I have also tried to use Decideable and prop equality in replace_f f a b var = if ⌊ Dec (var ≡ a) ⌋ then b else (f var) .
However, it errors with Set _p_391 !=< Dec _P_386 when checking that the expression Dec (var ≡ a) has type Dec _P_386
P. P. S.
If you want to reproduce the Decidable solution, use these imports
open import Relation.Binary.PropositionalEquality using (_≡_)
open import Relation.Nullary
open import Relation.Nullary.Decidable
open import Relation.Binary.Core
open import Data.Bool