I've been learning good old Haskell, mostly liking it, but one thing I really dislike is the way exceptions are handled.
It's frustrating that any function can throw just about anything, and this isn't reflected in it's type. Too many times my seemingly sound programs have came crashing down at runtime because some dependency decided to throw an exception. I much prefer the Rust way of doing things where errors are communicated by just returning a value describing it, and panics are reserved for serious trouble (out of memory and the like).
So with that in mind, is Idris for me? I assume that all the usual FP stuff is fine, but how are the exceptions handled?
Been forever since I used Haskell, and not used Idris (hi from scaled).
Currently actively developing in TypeScript with the fp library Effect.
It essentially has a tryCatch function to lift exceptions into an
Effect
(like anEither
type). Since TypeScript doesn't expose exceptions in the type system, its the only way to get errors from other libraries into the type system. They come in without types so we wrap them in our own errors types.Yeah I find myself doing something similar in Haskell too. Catching exceptions only to return them as
Left
.