u/MyFuncin r/scala • Recommends
Error handling with union types in Dotty
After watching Functional Scala - Adventures in Type-safe Error Handling by Jacob Wang and reading Introducing error reporting in optics, I was interested in exploring the use of union types in Dotty for error handling. By defining a type similar to `Either` but with `flatMap` returning the union of the two error types, it is possible to gain fine-grain tracking of errors. This is similar to hotpotato which uses Shapeless's coproduct for the error type.
Code together with more information in the readme can be found here-
https://github.com/Michaelt293/union-dotty