News for hackers. Stuff that matters.
Re:Inventing Monads by raiflip on Saturday August 29, 2020 @04:21PM (#24319140)
What if you need to access 5 resources in a row, any of which can throw exceptions? A monad centralizes the repeated logic in its flatMap function.
Re:Inventing Monads by edflsafoiewq on Saturday August 29, 2020 @04:29PM (#24319198)
I think the comparison is to something like this

  try:
    user = getUser()
    profile = getProfile(user)
    pic = getProfilePicture(profile)
    thumb = getThumbnail(pic)
    return thumb

  except Missing:
    return None
Re:Inventing Monads by raiflip on Saturday August 29, 2020 @04:55PM (#24319370)
That example seems a bit odd as a design. You’re throwing an exception to represent a no result, but suppressing it to convert the exception to a none. Monads give you the convenience while being consistent.
Re:Inventing Monads by Koshkin on Saturday August 29, 2020 @06:56PM (#24319997)
Well, the problem here is that using exceptions to implement the program’s logic is considered bad practice.