lean4-htt/tests/lean/run/677.lean
Kyle Miller fd15d8f9ed
feat: Lean.Expr.name? (#5760)
Adds a recognizer for `Name` literal expressions. Handles `Name`
constructors as well as the `Lean.Name.mkStr*` functions.
2024-10-18 02:40:26 +00:00

14 lines
344 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Lean
open Lean
def encodeDecode [ToJson α] [FromJson α] (x : α) : Except String α := do
let json := toJson x
fromJson? json
/-- info: `5 -/
#guard_msgs in
#eval IO.ofExcept <| encodeDecode (Name.mkNum Name.anonymous 5)
/-- info: `bla.«foo.boo» -/
#guard_msgs in
#eval IO.ofExcept <| encodeDecode (Name.mkStr `bla "foo.boo")