1. 2
  1.  

  2. 1

    I’ve read the readme and I still have no idea what it is or why should I use it.

    Make your functions return something meaningful, typed, and safe!

    Ok.. This doesn’t make any sense. My returns are typed and meaningful enough, thank you very much.

    Enforces better architecture

    How?! Bunch of typing doesn’t enforce better architecture and all of this anyway depends on the definition of “better”.

    Pythonic and pleasant to write and to read

    And the first example is this stuff:

    user: Optional[User]
    
    can_buy_stuff: Maybe[bool] = Maybe.new(user).map(  # type hint is not required
        lambda real_user: real_user.get_balance(),
    ).map(
        lambda balance: balance.credit_amount(),
    ).map(
        lambda balance_credit: balance_credit > 0,
    )
    

    This is just very unpythonic java in python syntax. It is said that it is beter than

    user: Optional[User]
    
    if user is not None:
         balance = user.get_balance()
         if balance is not None:
             balance_credit = balance.credit_amount()
             if balance_credit is not None and balance_credit > 0:
                 can_buy_stuff = True
    else:
        can_buy_stuff = False
    

    because this is long and contain a lot of fluff with checking the value to None (functions returning None when they should clearly raise errors are antipattern by itself). But this can be shortened to:

    try:
        can_buy_stuff = user.get_balance().credit_amount() > 0
    except AttributeError:
        can_buy_stuff = False
    

    This is imho perfectly readable and much better than chained maps with lambdas.