https://kotlinlang.org logo
#functional
Title
# functional
m

Mazhar Ibna Zahur

02/23/2023, 10:58 AM
how can i get the stacktrace of an error in functional style? throwing exception is not a right thing in FP.
t

Ties

02/23/2023, 11:01 AM
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

simon.vergauwen

02/23/2023, 11:15 AM
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

Mazhar Ibna Zahur

02/23/2023, 11:16 AM
thank you guys
t

Ties

02/23/2023, 11:17 AM
No worries 🙂 let me know if you need any help
w

wakingrufus

02/23/2023, 2:33 PM
for a more generic look at the concept, check out: https://fsharpforfunandprofit.com/posts/recipe-part2/
t

Ties

02/23/2023, 2:48 PM
Scott Wlaschin ❤️
3 Views