feat: add f!<interpolated string> macro for Format
This commit is contained in:
parent
7055f2ba7e
commit
5e0121c8dc
1 changed files with 18 additions and 0 deletions
18
src/Lean/Data/FormatMacro.lean
Normal file
18
src/Lean/Data/FormatMacro.lean
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#lang lean4
|
||||
/-
|
||||
Copyright (c) 2020 Microsoft Corporation. All rights reserved.
|
||||
Released under Apache 2.0 license as described in the file LICENSE.
|
||||
Authors: Leonardo de Moura
|
||||
-/
|
||||
import Lean.Data.Format
|
||||
namespace Lean
|
||||
|
||||
syntax:max "f!" (interpolatedStr term) : term
|
||||
|
||||
macro_rules
|
||||
| `(f! $interpStr) => do
|
||||
let chunks := interpStr.getArgs
|
||||
let r ← Lean.Syntax.expandInterpolatedStrChunks chunks (fun a b => `($a ++ $b)) (fun a => `(fmt $a))
|
||||
`(($r : Format))
|
||||
|
||||
end Lean
|
||||
Loading…
Add table
Reference in a new issue