chore: snake-case attributes

This commit is contained in:
Mario Carneiro 2022-10-18 16:57:37 -04:00
parent 96acc7269d
commit 39feeaab74
29 changed files with 51 additions and 51 deletions

View file

@ -22,7 +22,7 @@ namespace Lake
Converts a conveniently typed target facet build function into its
dynamically typed equivalent.
-/
@[macroInline] def mkTargetFacetBuild (facet : Name) (build : IndexBuildM α)
@[macro_inline] def mkTargetFacetBuild (facet : Name) (build : IndexBuildM α)
[h : FamilyDef TargetData facet α] : IndexBuildM (TargetData facet) :=
cast (by rw [← h.family_key_eq_type]) build
@ -81,7 +81,7 @@ def buildIndexTop' (info : BuildInfo) : RecBuildM (BuildData info.key) :=
Recursively build the given info using the Lake build index
and a topological / suspending scheduler and return the dynamic result.
-/
@[macroInline] def buildIndexTop (info : BuildInfo)
@[macro_inline] def buildIndexTop (info : BuildInfo)
[FamilyDef BuildData info.key α] : RecBuildM α := do
cast (by simp) <| buildIndexTop' info

View file

@ -55,7 +55,7 @@ lean_lib {root} \{
-- add library configuration options here
}
@[defaultTarget]
@[default_target]
lean_exe {pkgName} \{
root := `Main
}
@ -69,7 +69,7 @@ package {pkgName} \{
-- add package configuration options here
}
@[defaultTarget]
@[default_target]
lean_exe {exeRoot} \{
-- add executable configuration options here
}
@ -83,7 +83,7 @@ package {pkgName} \{
-- add package configuration options here
}
@[defaultTarget]
@[default_target]
lean_lib {libRoot} \{
-- add library configuration options here
}
@ -100,7 +100,7 @@ package {pkgName} \{
require mathlib from git
\"https://github.com/leanprover-community/mathlib4.git\"
@[defaultTarget]
@[default_target]
lean_lib {libRoot} \{
-- add any library configuration options here
}

View file

@ -12,25 +12,25 @@ initialize packageAttr : TagAttribute ←
registerTagAttribute `package "mark a definition as a Lake package configuration"
initialize packageDepAttr : TagAttribute ←
registerTagAttribute `packageDep "mark a definition as a Lake package dependency"
registerTagAttribute `package_dep "mark a definition as a Lake package dependency"
initialize scriptAttr : TagAttribute ←
registerTagAttribute `script "mark a definition as a Lake script"
initialize leanLibAttr : TagAttribute ←
registerTagAttribute `leanLib "mark a definition as a Lake Lean library target configuration"
registerTagAttribute `lean_lib "mark a definition as a Lake Lean library target configuration"
initialize leanExeAttr : TagAttribute ←
registerTagAttribute `leanExe "mark a definition as a Lake Lean executable target configuration"
registerTagAttribute `lean_exe "mark a definition as a Lake Lean executable target configuration"
initialize externLibAttr : TagAttribute ←
registerTagAttribute `externLib "mark a definition as a Lake external library target"
registerTagAttribute `extern_lib "mark a definition as a Lake external library target"
initialize targetAttr : TagAttribute ←
registerTagAttribute `target "mark a definition as a custom Lake target"
initialize defaultTargetAttr : TagAttribute ←
registerTagAttribute `defaultTarget "mark a Lake target as the package's default"
registerTagAttribute `default_target "mark a Lake target as the package's default"
fun name => do
let valid ← getEnv <&> fun env =>
leanLibAttr.hasTag env name ||
@ -38,13 +38,13 @@ initialize defaultTargetAttr : TagAttribute ←
externLibAttr.hasTag env name ||
targetAttr.hasTag env name
unless valid do
throwError "attribute `defaultTarget` can only be used on a target (e.g., `lean_lib`, `lean_exe`)"
throwError "attribute `default_target` can only be used on a target (e.g., `lean_lib`, `lean_exe`)"
initialize moduleFacetAttr : TagAttribute ←
registerTagAttribute `moduleFacet "mark a definition as a Lake module facet"
registerTagAttribute `module_facet "mark a definition as a Lake module facet"
initialize packageFacetAttr : TagAttribute ←
registerTagAttribute `packageFacet "mark a definition as a Lake package facet"
registerTagAttribute `package_facet "mark a definition as a Lake package facet"
initialize libraryFacetAttr : TagAttribute ←
registerTagAttribute `libraryFacet "mark a definition as a Lake library facet"
registerTagAttribute `library_facet "mark a definition as a Lake library facet"

View file

@ -27,7 +27,7 @@ during the Lakefile's elaboration.
-/
scoped syntax (name := dirConst) "__dir__" : term
@[termElab dirConst]
@[term_elab dirConst]
def elabDirConst : TermElab := fun stx expectedType? => do
let exp :=
if let some dir := dirExt.getState (← getEnv) then
@ -47,7 +47,7 @@ or via the `with` clause in a `require` statement.
-/
scoped syntax (name := getConfig) "get_config? " ident :term
@[termElab getConfig]
@[term_elab getConfig]
def elabGetConfig : TermElab := fun stx expectedType? => do
tryPostponeIfNoneOrMVar expectedType?
match stx with

View file

@ -34,7 +34,7 @@ doc?:optional(docComment) attrs?:optional(Term.attributes)
kw:"module_facet " sig:buildDeclSig : command => do
match sig with
| `(buildDeclSig| $id:ident $[$mod?]? : $ty := $defn $[$wds?]?) =>
let attr ← withRef kw `(Term.attrInstance| moduleFacet)
let attr ← withRef kw `(Term.attrInstance| module_facet)
let attrs := #[attr] ++ expandAttrs attrs?
let name := Name.quoteFrom id id.getId
let facetId := mkIdentFrom id <| id.getId.modifyBase (.str · "_modFacet")
@ -63,7 +63,7 @@ doc?:optional(docComment) attrs?:optional(Term.attributes)
kw:"package_facet " sig:buildDeclSig : command => do
match sig with
| `(buildDeclSig| $id:ident $[$pkg?]? : $ty := $defn $[$wds?]?) =>
let attr ← withRef kw `(Term.attrInstance| packageFacet)
let attr ← withRef kw `(Term.attrInstance| package_facet)
let attrs := #[attr] ++ expandAttrs attrs?
let name := Name.quoteFrom id id.getId
let facetId := mkIdentFrom id <| id.getId.modifyBase (.str · "_pkgFacet")
@ -92,7 +92,7 @@ doc?:optional(docComment) attrs?:optional(Term.attributes)
kw:"library_facet " sig:buildDeclSig : command => do
match sig with
| `(buildDeclSig| $id:ident $[$lib?]? : $ty := $defn $[$wds?]?) =>
let attr ← withRef kw `(Term.attrInstance| libraryFacet)
let attr ← withRef kw `(Term.attrInstance| library_facet)
let attrs := #[attr] ++ expandAttrs attrs?
let name := Name.quoteFrom id id.getId
let facetId := mkIdentFrom id <| id.getId.modifyBase (.str · "_libFacet")
@ -159,7 +159,7 @@ doc?:optional(docComment) attrs?:optional(Term.attributes)
"extern_lib " spec:externLibDeclSpec : command => do
match spec with
| `(externLibDeclSpec| $id:ident $[$pkg?]? := $defn $[$wds?]?) =>
let attr ← `(Term.attrInstance| externLib)
let attr ← `(Term.attrInstance| extern_lib)
let attrs := #[attr] ++ expandAttrs attrs?
let pkgName := mkIdentFrom id `_package.name
let targetId := mkIdentFrom id <| id.getId.modifyBase (· ++ `static)

View file

@ -23,14 +23,14 @@ def expandDepSpec : TSyntax ``depSpec → MacroM Command
let rev ← match rev? with | some rev => `(some $rev) | none => `(none)
let path ← match path? with | some path => `(some $path) | none => `(none)
let opts := opts?.getD <| ← `({})
`(@[packageDep] def $name : Dependency := {
`(@[package_dep] def $name : Dependency := {
name := $(quote name.getId),
src := Source.git $url $rev $path,
options := $opts
})
| `(depSpec| $name:ident from $path:term $[with $opts?]?) => do
let opts := opts?.getD <| ← `({})
`(@[packageDep] def $name : Dependency := {
`(@[package_dep] def $name : Dependency := {
name := $(quote name.getId),
src := Source.path $path,
options := $opts

View file

@ -31,7 +31,7 @@ lean_lib «target-name» := /- config -/
scoped macro (name := leanLibDecl)
doc?:optional(docComment) attrs?:optional(Term.attributes)
"lean_lib " sig:structDeclSig : command => do
let attr ← `(Term.attrInstance| leanLib)
let attr ← `(Term.attrInstance| lean_lib)
let ty := mkCIdentFrom (← getRef) ``LeanLibConfig
let attrs := #[attr] ++ expandAttrs attrs?
mkConfigStructDecl none doc? attrs ty sig
@ -51,7 +51,7 @@ lean_exe «target-name» := /- config -/
scoped macro (name := leanExeDecl)
doc?:optional(docComment) attrs?:optional(Term.attributes)
"lean_exe " sig:structDeclSig : command => do
let attr ← `(Term.attrInstance| leanExe)
let attr ← `(Term.attrInstance| lean_exe)
let ty := mkCIdentFrom (← getRef) ``LeanExeConfig
let attrs := #[attr] ++ expandAttrs attrs?
mkConfigStructDecl none doc? attrs ty sig

View file

@ -31,7 +31,7 @@ where
throw s!"unexpected type at '{const}', `{type}` expected"
/-- Like `Lean.Environment.evalConstCheck`, but with plain universe-polymorphic `Except`. -/
@[implementedBy unsafeEvalConstCheck] opaque evalConstCheck
@[implemented_by unsafeEvalConstCheck] opaque evalConstCheck
(env : Environment) (opts : Options) (α) (type : Name) (const : Name) : Except String α
/-- Construct a `NameMap` from the declarations tagged with `attr`. -/

View file

@ -45,7 +45,7 @@ abbrev FunBinder := TSyntax ``Term.funBinder
instance : Coe BinderIdent FunBinder where
coe s := ⟨s.raw⟩
@[runParserAttributeHooks]
@[run_parser_attribute_hooks]
def binder := Term.binderIdent <|> Term.bracketedBinder
abbrev Binder := TSyntax ``binder

View file

@ -88,7 +88,7 @@ instance : LawfulCmpEq String compare where
eq_of_cmp := eq_of_compareOfLessAndEq
cmp_rfl := compareOfLessAndEq_rfl <| String.lt_irrefl _
@[macroInline]
@[macro_inline]
def Option.compareWith (cmp : αα → Ordering) : Option α → Option α → Ordering
| none, none => .eq
| none, some _ => .lt

View file

@ -11,7 +11,7 @@ open Lean Elab
unsafe def unsafeEvalTerm (α) [ToExpr α] (term : Syntax) : TermElabM α := do
Term.evalTerm α (toTypeExpr α) term .unsafe
@[implementedBy unsafeEvalTerm]
@[implemented_by unsafeEvalTerm]
opaque evalTerm (α) [ToExpr α] (term : Syntax) : TermElabM α
/-! ## ToExpr Instances -/

View file

@ -143,11 +143,11 @@ export FamilyDef (family_key_eq_type)
attribute [simp] family_key_eq_type
/-- Cast a datum from its individual type to its general family. -/
@[macroInline] def toFamily [FamilyDef Fam a β] (b : β) : Fam a :=
@[macro_inline] def toFamily [FamilyDef Fam a β] (b : β) : Fam a :=
cast family_key_eq_type.symm b
/-- Cast a datum from its general family to its individual type. -/
@[macroInline] def ofFamily [FamilyDef Fam a β] (b : Fam a) : β :=
@[macro_inline] def ofFamily [FamilyDef Fam a β] (b : Fam a) : β :=
cast family_key_eq_type b
/--

View file

@ -38,11 +38,11 @@ macro (name := hydrateOpaqueType)
`(
namespace $oty
unsafe def $unsafeMk : $ty $args* → $oty $args* := unsafeCast
@[implementedBy $unsafeMk] opaque $mk : $ty $args* → $oty $args*
@[implemented_by $unsafeMk] opaque $mk : $ty $args* → $oty $args*
instance : Coe ($ty $args*) ($oty $args*) := ⟨$mk⟩
unsafe def $unsafeGet : $oty $args* → $ty $args* := unsafeCast
@[implementedBy $unsafeGet] opaque $get $[{$args}]* : $oty $args* → $ty $args*
@[implemented_by $unsafeGet] opaque $get $[{$args}]* : $oty $args* → $ty $args*
instance : Coe ($oty $args*) ($ty $args*) := ⟨$get⟩
instance [Inhabited ($ty $args*)] : Inhabited ($oty $args*) := ⟨$mk default⟩

View file

@ -3,4 +3,4 @@ open System Lake DSL
package a
require root from ".."/"root"
@[defaultTarget] lean_lib A
@[default_target] lean_lib A

View file

@ -3,4 +3,4 @@ open System Lake DSL
package b
require root from ".."/"root"
@[defaultTarget] lean_lib B
@[default_target] lean_lib B

View file

@ -7,6 +7,6 @@ require foo from ".."/"foo"
lean_lib Bar
@[defaultTarget]
@[default_target]
lean_exe bar where
root := `Main

View file

@ -8,6 +8,6 @@ require b from ".."/"b"
lean_lib Foo
@[defaultTarget]
@[default_target]
lean_exe foo where
root := `Main

View file

@ -2,4 +2,4 @@ import Lake
open Lake DSL
package root
@[defaultTarget] lean_lib Root
@[default_target] lean_lib Root

View file

@ -5,7 +5,7 @@ package app
require ffi from ".."/"lib"
@[defaultTarget]
@[default_target]
lean_exe app {
root := `Main
}

View file

@ -8,7 +8,7 @@ package ffi {
lean_lib FFI
@[defaultTarget] lean_exe test {
@[default_target] lean_exe test {
root := `Main
}

View file

@ -7,7 +7,7 @@ package git_hello
require hello from
git "../.."/"examples"/"hello"
@[defaultTarget]
@[default_target]
lean_exe git_hello {
root := `Main
}

View file

@ -5,7 +5,7 @@ package hello
lean_lib Hello
@[defaultTarget]
@[default_target]
lean_exe hello {
root := `Main
}

View file

@ -7,5 +7,5 @@ package bar {
require foo from "../foo"
@[defaultTarget]
@[default_target]
lean_lib Bar

View file

@ -5,5 +5,5 @@ package foo {
precompileModules := true
}
@[defaultTarget]
@[default_target]
lean_lib foo

View file

@ -5,7 +5,7 @@ package targets {
srcDir := "src"
}
@[defaultTarget]
@[default_target]
lean_lib foo
lean_lib bar
lean_lib baz
@ -13,10 +13,10 @@ lean_lib baz
lean_exe a
lean_exe b
@[defaultTarget]
@[default_target]
lean_exe c
@[defaultTarget]
@[default_target]
target meow (pkg : Package) : Unit := do
IO.FS.writeFile (pkg.buildDir / "meow.txt") "Meow!"
return .nil

View file

@ -5,7 +5,7 @@ package tba {
-- add package configuration options here
}
@[defaultTarget]
@[default_target]
lean_lib TBA := {
name := `TBA
globs := #[.andSubmodules `TBA]

View file

@ -11,7 +11,7 @@ def url : String :=
require hello from git url / "examples" / "hello"
@[defaultTarget]
@[default_target]
lean_exe test {
root := `Main
}

View file

@ -5,5 +5,5 @@ package foo where
moreLeanArgs := get_config? leanArgs |>.getD "" |>.splitOn " " |>.toArray
moreLeancArgs := get_config? leancArgs |>.getD "" |>.splitOn " " |>.toArray
@[defaultTarget]
@[default_target]
lean_exe foo

View file

@ -9,7 +9,7 @@ lean_lib Foo {
-- add library configuration options here
}
@[defaultTarget]
@[default_target]
lean_exe foo {
root := `Main
}