dbrattli / Expression

Functional programming for Python
https://expression.readthedocs.io
MIT License
470 stars 31 forks source link

__str__ and __repr__ of Failure & Success #179

Closed u3kkasha closed 8 months ago

u3kkasha commented 10 months ago

Describe the bug When using str or repr on Try, it prints the representations of the parent class

To Reproduce

from expression import Try, Success, Failure
print( Success(8) )
print( Failure(8) )

Output: Ok 8 Error 8

Expected behavior Output: Success 8 Failure 8

Additional context

dbrattli commented 8 months ago

Hey, thanks for opening this issue. I'm adding a fix for this now, just to tell that both Result and Try works a bit differently in Expression v5. Try is not an alias of Result, but subclasses Result in order to inherit all the member method handling. This mean that Try still have the ok and error cases when pattern matching. Haven't found a way around this yet without making a full reimplementation. I'll consider a way to fix this if I can find one going forwards.