kowainik / eio

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

Introduce `Throws` typeclass #5

Open chshersh opened 3 years ago

chshersh commented 3 years ago

Currently, we need to specify list of exceptions precisely. But the order of exceptions in the list doesn't actually matter. So the following two actions are the same, but they won't typecheck to each other:

foo :: EIO '[ E1, E2 ] Int
bar :: EIO '[ E2, E1 ] Int

This is usually handled by typeclasses:

foo :: Throws e '[ E1, E2 ] => EIO e Int