Try.* functions
PR #29 highlighted how there's a set of functions from Scala\Haskell that we haven't considered. In particular Try.map from Scala acts as a functor on Try objects, applying a function in case no exception was thrown.
Currently we have Either.try which maps a function application to an either, i.e., :ok if the function succeeded, :error if an exception was thrown.
A few questions from the top of my head:
- do we need
Try.mapwhen the user could use thewithconstruct? (or justmapafter theEither.try) - are there other functions outside of
Either.trythat we could implement? - would it make sense to treat
Tryas a separate module (i.e. not piggybacking oneither)?
@paolosimone @neslinesli93 @cottinisimone
Ehi @sphaso, How are you?
About this i think that even if with the with construct you can achieve this behavior this function (that i would add in a separate Try module) might add some extra sugar that might be useful. I would implement some functions like map, map_error and try (just catch the exception and returns something got from params wrapped in an error {:error, something})
Hi @cottinisimone thanks for your feedback! if you want to work on this let me know, it would be great :)
Ok, i'll find some free time to contribute in this!