They don’t work in a functionally-oriented language.
No other modern language has them.
I don’t think this is true. Some counter-examples:
Also, arguably Koka: GitHub - koka-lang/koka: Koka language compiler and interpreter
Note that both are functional languages. Really anything with some form of extensible effect/coeffect system lets you do something akin to checked exceptions in a very functional context.
The “problem” with checked exceptions and functional languages as I see it is that most languages with functional features do not have good support for “graded” categorical structures. From what I remember, these ideas are fairly new (I wrote my master’s thesis on the topic – but it’s been awhile since I’ve actively studied the topic). For instance, this paper was published in 2016.
For instance, people often give the example of a “visit” function. Here’s what that would look like with a graded “MonadThrows” monad that models checked exceptions in Haskell:
visit :: MonadThrows m e => [a] -> (a -> m e ()) -> m e ()
The exception type
e is propogated out of the lambda in the second argument.
For even better usability (this is where lack of language support for graded structures comes in) you really want to have something that looks like this (using a pseudo-haskell syntax) for a monadic bind:
class GradedMonad m e where identity :: e return :: a -> m identity a bind :: m e1 a -> (a -> m e2 b) -> m (e1 | e2) b
| is a union type, so for instance to give a really contrived example you could do things like:
test :: MonadThrow m (IOException | SomeOtherException) () test = do contents <- readFile "test.txt" if contents == "" then throw SomeOtherException else putStrLn contents