feat(library/init/lean/attributes): add ParametricAttribute.setParam
This commit is contained in:
parent
0dfca42f6d
commit
dbe7078e80
1 changed files with 8 additions and 0 deletions
|
|
@ -325,6 +325,14 @@ match env.getModuleIdxFor decl with
|
|||
| none := none
|
||||
| none := (attr.ext.getState env).find decl
|
||||
|
||||
def setParam {α : Type} (attr : ParametricAttribute α) (env : Environment) (decl : Name) (param : α) : Except String Environment :=
|
||||
if (env.getModuleIdxFor decl).isNone then
|
||||
Except.error ("invalid '" ++ toString attr.attr.name ++ "'.setParam, declaration is in an imported module")
|
||||
else if ((attr.ext.getState env).find decl).isSome then
|
||||
Except.error ("invalid '" ++ toString attr.attr.name ++ "'.setParam, attribute has already been set")
|
||||
else
|
||||
Except.ok (attr.ext.addEntry env (decl, param))
|
||||
|
||||
end ParametricAttribute
|
||||
|
||||
end Lean
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue