lean4-htt/tests/lean/run/instanceWhere.lean
Leonardo de Moura 5884b9c19a feat: add support for instance ... where
@Kha The fields are not mutually recursive yet, but it is good enough
 for writing examples in the manual.

See new test
2020-11-23 18:07:02 -08:00

23 lines
534 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.

namespace Exp
universes u v w
def StateT' (σ : Type u) (m : Type u → Type v) (α : Type u) : Type (max u v) :=
σ → m (α × σ)
instance [Monad m] : Monad (StateT' σ m) where
pure a := fun s => pure (a, s)
bind x f := fun s => do
let (a, s) ← x s
f a s
map f x := fun s => do
let (a, s) ← x s
pure (f a, s)
instance [ToString α] [ToString β] : ToString (Sum α β) where
toString : Sum α β → String
| Sum.inr a => "inl" ++ toString a
| Sum.inl b => "inr" ++ toString b
end Exp