Zulip Chat Archive
Stream: lean4
Topic: inline extract value from monad
Locria Cyber (Aug 25 2022 at 13:02):
I currently have
def fromLines : List String -> Option (List Nat)
| [] => some []
| (x :: xs) => do
let x' <- x.data.mapA charToNat
let xs' <- fromLines xs
x' ++ xs'
Is there a shorter way to write this? e.g. (x' ++ extract_keyword! (fromLines xs))
Henrik Böving (Aug 25 2022 at 13:05):
You can do stuff like
let x := (<-a) + (<-b)
The () around the "inline" arrows are important
Last updated: Dec 20 2023 at 11:08 UTC