Monads in Lean

5 points by abhin4v


jkoppel

Do-notation and typeclasses are among the best ideas in Haskell. Good to see another language pick them up.

Fun fact: when monads were first introduced into Haskell, the proposed syntax was to do everything like list comprehensions.

So instead of:

x = do
  a <- Map.get m "key"
  b <- Map.get m a
  return b

You would write

[b | a <- Map.get m "key", b <- Map.get m a]
pervognsen

I didn't see a mention of Lean's extensions to do-notation that make it more like conventional imperative programming and perhaps how that ties into program verification, which if you're already familiar with monads and do-notation might be more interesting.