3 ms·
Doesn't Scala have transformer libraries like ExceptT in Haskell. Aside, much of what this comment thread is about, is similar in Haskell-land as well. Anyway,
by mhitza 6y ago
Doesn't Scala have transformer libraries like ExceptT in Haskell. Aside, much of what this comment thread is about, is similar in Haskell-land as well.
Anyway, a pattern I've started to use in Haskell with ExceptT is along the lines of
handledIo = runExceptT $ do
failable <- someIo
can_handle <- anotherIo failable `catchError` handlerOfSubsetOfExceptionsOrRethrows
return $ updateState can_handle
So the code still remains legible (minus the plethora of Haskell operators, data wrappers and unwrappers :)), I can trap individual exceptions along the way, which I can handle. And at the end unhandled exceptions are returned by the function as Left.