Add Try type to Fugue
Is there interest in adding Try type to Fugue similar to that which is found in Scala i.e this.
I am happy to do the work but thought it was worth checking if there was interest before starting.
Comments (7)
-
-
reporter The high level goal is to implement something slightly friendlier than either to represent the result of an operation that can potentially fail as I have found some people find Either used this was as unintuitive.
So I will go away and have a think about what a potential API could look like and if we can make it obey the monadic laws. I will come back with a sketch of an API once I have something.
-
reporter I have pushed a branch with a pretty minimal implementation of Try along with some tests that highlight how it breaks the monad laws. https://bitbucket.org/atlassian/fugue/branch/try-spike#diff
-
reporter Add an initial implimentation of Try
A safety first implemetnation of Try has been added, it will automatically catch an wrap an exceptions throw by the provided function in map etc with a Failure. See issue
#57for further information.→ <<cset e2b1622af276>>
-
reporter Add an initial implimentation of Try
A safety first implemetnation of Try has been added, it will automatically catch an wrap an exceptions throw by the provided function in map etc with a Failure. See issue
#57for further information.→ <<cset 55cc87a30616>>
-
reporter Add an initial implimentation of Try
A safety first implemetnation of Try has been added, it will automatically catch an wrap an exceptions throw by the provided function in map etc with a Failure. See issue
#57for further information.→ <<cset 55cc87a30616>>
-
reporter - edited description
- changed status to resolved
Included in 4.4.0
- Log in to comment
Can you expand on you're implementation goals? Some care needs be taken to figure out if you can properly obey the monad laws or not. The Scala implementation chooses not to in certain circumstances and I cannot remember if you can avoid that given your own implementation. Some initial googling on the original problem to help recover some of the original discussions: https://gist.github.com/ms-tg/6222775, http://stackoverflow.com/questions/29716205/is-it-try-a-monad-if-unit-success
Following that; Try[+A] being similar to Either[Exception, +A] suggests it would be helpful to compare the list of operations Either supports that Try does not and vice versa. That would help find the extra helper methods you want to add and which old methods you may want to remove. It may also inform the actual implementation.