dh-core
dh-core copied to clipboard
datasets : add exceptions
currently, the parsers error and fail here and there. Since these are synchronous exceptions, it would be better to use MonadThrow, which can be conveniently used at a "pure" type such as Maybe or Either.
- add
exceptionsas dependency - import Control.Monad.Catch (MonadThrow(..))
- declare some parsing exceptions type (which require Typable and Exception instances, see https://www.fpcomplete.com/blog/2016/11/exceptions-best-practices-haskell)
- convert the calls to
errorandfailinto calls tothrowM
I've been working on this a bit already with safe-exceptions via #22 (and PR #31 ).
There is a question of how to treat safe vs unsafe code. For instance, from #31, is the right thing to have a readDataset :: x paired with a safeReadDataset :: MonadThrow m => m x or an unsafeReadDataset :: x paired with a readDataset :: MonadThrow m => m x?