Zulip Chat Archive
Stream: general
Topic: How to use do notation
Konstantin Weitz (Jul 15 2025 at 19:35):
I'm trying to get do notation to work, but even a simple example like this one fails for me:
def State T := StateM Nat T
def inc : State Unit :=
fun n => ((), n+1)
def get : State Nat :=
fun n => (n, n)
def program : State Nat := do
inc
get
with this error message for the inc call.
failed to synthesize
Bind State
Lean 4
What am I doing wrong?
Aaron Liu (Jul 15 2025 at 19:36):
make def State into abbrev State
Aaron Liu (Jul 15 2025 at 19:36):
this will allow typeclass to see through its definition
Konstantin Weitz (Jul 15 2025 at 19:42):
Wonderful, that worked, thanks!
Last updated: Dec 20 2025 at 21:32 UTC