This PR changes the signature of `Array.set` to take a `Nat`, and a tactic-provided bound, rather than a `Fin`. Corresponding changes (but without the auto-param) for `Array.get` will arrive shortly, after which I'll go more pervasively through the Array API.
36 lines
897 B
Text
36 lines
897 B
Text
/-
|
|
Copyright (c) 2020 Microsoft Corporation. All rights reserved.
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
Authors: Leonardo de Moura, Mario Carneiro
|
|
-/
|
|
|
|
prelude
|
|
import Init.Data.Array.Set
|
|
|
|
/-!
|
|
# Helper functions for `Syntax`.
|
|
|
|
These are delayed here to allow some time to bootstrap `Array`.
|
|
-/
|
|
|
|
namespace Lean.Syntax
|
|
|
|
/--
|
|
Updates the argument list without changing the node kind.
|
|
Does nothing for non-`node` nodes.
|
|
-/
|
|
def setArgs (stx : Syntax) (args : Array Syntax) : Syntax :=
|
|
match stx with
|
|
| node info k _ => node info k args
|
|
| stx => stx
|
|
|
|
/--
|
|
Updates the `i`'th argument of the syntax.
|
|
Does nothing for non-`node` nodes, or if `i` is out of bounds of the node list.
|
|
-/
|
|
def setArg (stx : Syntax) (i : Nat) (arg : Syntax) : Syntax :=
|
|
match stx with
|
|
| node info k args => node info k (args.setD i arg)
|
|
| stx => stx
|
|
|
|
end Lean.Syntax
|