lean4-htt/library/Init/Lean/Compiler/NeverExtractAttr.lean
Leonardo de Moura a2abbdbf9a chore: fix imports using script
This is just a draft.
```
for f in `find . -name '*.lean'`; do echo $f; gsed "/^import/s/\b\(.\)/\u\1/g" $f > tmp; gsed "/^Import/s/Import/import/g" tmp > $f; done
```
2019-10-04 14:34:58 -07:00

28 lines
992 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 mkNeverExtractAttr : IO TagAttribute :=
registerTagAttribute `neverExtract "instruct the compiler that function applications using the tagged declaration should not be extracted when they are closed terms, nor common subexpression should be performed. This is useful for declarations that have implicit effects."
@[init mkNeverExtractAttr]
constant neverExtractAttr : TagAttribute := default _
private partial def hasNeverExtractAttributeAux (env : Environment) : Name → Bool
| n =>
neverExtractAttr.hasTag env n
||
(n.isInternal && hasNeverExtractAttributeAux n.getPrefix)
@[export lean_has_never_extract_attribute]
def hasNeverExtractAttribute (env : Environment) (n : Name) : Bool :=
hasNeverExtractAttributeAux env n
end Lean