kowainik / eio

🎯 IO with Exceptions tracked on the type-level
Mozilla Public License 2.0
58 stars 2 forks source link

Type of catch #10

Closed mheinzel closed 3 years ago

mheinzel commented 3 years ago

Nice use of QualifiedDo, this seems like a cool approach!

There's one detail that I wondered about, though (might just be that I'm missing something). The current type of catch is:

catch
    :: forall e a e1 e2
    .  Exception e
    => EIO e1 a
    -> (e -> EIO e2 a)
    -> EIO (Delete e (e1 <> e2)) a

Shouldn't it result in EIO (Delete e e1 <> e2) instead? If another exception of the type e is thrown in the exception handler, it will not be caught as far as I know.

For example the following will still result in an uncaught exception:

EIO.throw MyErr `EIO.catch` (\MyErr -> EIO.throw MyErr) :: EIO '[] ()
chshersh commented 3 years ago

@mheinzel Good catch! I agree that the new type signature can describe the behaviour better. PRs are welcome 🙂

chshersh commented 3 years ago

Closed in #11