how can i get the stacktrace of an error in functi...
# functional
m
how can i get the stacktrace of an error in functional style? throwing exception is not a right thing in FP.
t
You could use Kotlins Result type, or the Either type from Arrow (or the fancy new solution with context receivers), or build your own Result type that contains an exception 🙂
s
https://github.com/arrow-kt/arrow/pull/2816 This PR has been open for some time, and it solves the issue for 90%... I am still trying to get feedback on it. 90% in the sense that it can track the
bind()
or
raise
that failed the issue but if you reify into a couple intermediate values in between than it can only track up until the latest point that actually "raised" or short-circuited the DSL.
Any, or all feedback would be greatly appreciated! I think this is still a great feature to have in Arrow, since it can greatly improve the situation of working with functional errors.
m
thank you guys
t
No worries 🙂 let me know if you need any help
w
for a more generic look at the concept, check out: https://fsharpforfunandprofit.com/posts/recipe-part2/
t
Scott Wlaschin ❤️