lean4-htt/tests/lean/run/setStructInstNotation.lean
Leonardo de Moura 9e27e92eea
chore: set literal notation (#3348)
Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-02-19 23:22:36 +00:00

68 lines
1.2 KiB
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.

structure Foo where
a : Nat
b : Nat
def bla (x : Foo) : IO Unit := do
let { a, b } := x
def Set (α : Type u) := α → Prop
def setOf {α : Type u} (p : α → Prop) : Set α :=
p
namespace Set
protected def mem (a : α) (s : Set α) :=
s a
instance : Membership α (Set α) :=
⟨Set.mem⟩
protected def subset (s₁ s₂ : Set α) :=
∀ {a}, a ∈ s₁ → a ∈ s₂
instance : EmptyCollection (Set α) :=
⟨λ a => false⟩
protected def insert (a : α) (s : Set α) : Set α :=
fun b => b = a b ∈ s
protected def singleton (a : α) : Set α :=
fun b => b = a
instance : Insert α (Set α) := ⟨Set.insert⟩
instance : Singleton α (Set α) := ⟨Set.singleton⟩
#check { 1, 2 } -- Set Nat
end Set
def f1 (a b : Nat) : Set Nat :=
{ a, b }
def f2 (a b : Nat) : Foo :=
{ a, b }
def f3 (a b : Nat) : Set Nat :=
{ a, b }
#check f3 -- Nat → Nat → Set Nat
def f4 (a b : α) : Set α :=
{ a, b }
#check @f4 -- {α : Type u_1} → αα → Set α
def f5 (a b : Nat) :=
{ a, b : Foo }
def boo1 (x : Foo) : IO Unit :=
let { a, b } := x
pure ()
def boo2 (x : Foo) : IO Unit := do
let { a, b } := x
pure ()
def boo3 (x : Nat → IO Foo) : IO Nat := do
let { a, b } ← x 0
return a + b