24 lines
397 B
Text
24 lines
397 B
Text
class Foo (α β : Type) :=
|
||
(f : α → β)
|
||
|
||
export Foo (f)
|
||
|
||
@[defaultInstance]
|
||
instance : Foo Nat Nat := {
|
||
f := id
|
||
}
|
||
|
||
@[defaultInstance]
|
||
instance : Foo String String := {
|
||
f := id
|
||
}
|
||
|
||
def g (x : Nat) := f x -- works
|
||
|
||
def h (x : String) := f x -- works
|
||
|
||
def r (x : Bool) := f x -- error
|
||
|
||
def r [Foo Bool Nat] (x : Bool) := f x -- error
|
||
|
||
def r [Foo Bool Nat] (x : Bool) := (f x : Nat) -- works
|