lean4-htt/library/init/lean/compiler/effectfulattr.lean
Leonardo de Moura e451c4dc78 feat(library/init/lean/compiler): add @[effectful]
This attribute is used for low-level primitives like unsafeIO
2019-09-30 16:12:41 -07:00

22 lines
699 B
Text

/-
Copyright (c) 2019 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
prelude
import init.lean.environment
import init.lean.attributes
namespace Lean
def mkEffectfulAttr : IO TagAttribute :=
registerTagAttribute `effectful "mark that a declaration has implicit effects, and the compiler should avoid optimizations such as common subexpression elimination and closed term extraction"
@[init mkEffectfulAttr]
constant effectfulAttr : TagAttribute := default _
@[export lean_has_effectful_attribute]
def hasEffectfulAttribute (env : Environment) (n : Name) : Bool :=
effectfulAttr.hasTag env n
end Lean