What about
let getUser = async (id) => {
lets Ok(user) = await fetchUser(id)
lets Ok(decodedUser) = decodeUser(user)
Console.log(`Got user ${decodedUser.name}!`)
lets Ok() = await ensureUserActive(decodedUser)
Ok(decodedUser)
}
- No symbols
- Is a proper word
- “s” is reminiscent of “throwS”, but emphasizing the prevailing importance of the passing part rather than the throwing one, kind of a counterpart of “throwS”, as in “lets the value pass” rather than emphasizing “throws an error”
- Or maybe reminiscent of “[S]witch” that this hides
Or
let getUser = async (id) => {
let/ Ok(user) = await fetchUser(id)
let/ Ok(decodedUser) = decodeUser(user)
Console.log(`Got user ${decodedUser.name}!`)
let/ Ok() = await ensureUserActive(decodedUser)
Ok(decodedUser)
}
- Is very clear – the dash is a much cleaner symbol than “?” which is very muddy, one of the muddiest tbh
- Let’s you focus on the meaningful text to the right of it easier while reminding us that the meta is let
- The dash is very visible and lets you see all such lets in the code immediately
- Is on the same key as “?” on many keyboards, but doesn’t require you pressing Shift all the time
Or
let getUser = async (id) => {
let| Ok(user) = await fetchUser(id)
let| Ok(decodedUser) = decodeUser(user)
Console.log(`Got user ${decodedUser.name}!`)
let| Ok() = await ensureUserActive(decodedUser)
Ok(decodedUser)
}
- Same pros as “/”, but reminds of how “|” is used in such languages, and, again, of the
switchsyntax that it’s “hiding” - But it needs you holding Shift…