Hacker News new | ask | show | jobs
by eemax 2682 days ago
The library described in this blog post looks kind of interesting as an implementation of a Maybe monad in python, but the example case is pretty silly.

It re-implements a 4 line function as a 13 line class, but the logic at the caller doesn't get any simpler:

  try:
     result = get_user_profile(id)
  except:
     # handle any exceptions...
vs. with the library:

  result = FetchUserProfile(id)
  if (result is a Failure):
    # handle the failure
  # do something with the result