lean4-htt/tests/lean/run/overloaded.lean
Leonardo de Moura 9d304df757 feat: heterogeneous Append experiment
@Kha This one required a bunch of manual fixes. The main issue is that
before we added the string interpolation feature, we created
`MessageData`s using `++` and coercions. For example, given
`(e : Expr)`, we would write
```
let msg : MessageData := "type: " ++ e
```
and rely on the coercions `String -> MessageData` and
`Expr -> MessageData`, and the instance `Append MessageData`.
However, heterogeneous operators "block" the expected type propagation downwards.
This kind of code is obsolete now since we can write a more compact
version using string interpolation
```
let msg := m!"type: {e}"
```
2020-12-01 16:32:41 -08:00

22 lines
404 B
Text

--
def A.x : Nat := 10
def B.x : String := "hello"
def f (a : Nat) := a + 1
def g (s : String) := s ++ " world"
open A
open B
#check f x
#check g x
macro "foo!" x:term : term => `($x + (1:Nat))
macro "foo!" x:term : term => `(Append.append $x " world")
#check f (foo! 1)
#check g (foo! "hello")
macro "bla!" : term => `((1 : Nat))
macro "bla!" : term => `("hello world")
#check f bla!
#check g bla!