dh-core icon indicating copy to clipboard operation
dh-core copied to clipboard

datasets : add exceptions

Open ocramz opened this issue 7 years ago • 1 comments

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.

  1. add exceptions as dependency
  2. import Control.Monad.Catch (MonadThrow(..))
  3. declare some parsing exceptions type (which require Typable and Exception instances, see https://www.fpcomplete.com/blog/2016/11/exceptions-best-practices-haskell)
  4. convert the calls to error and fail into calls to throwM

ocramz avatar Jan 01 '19 10:01 ocramz

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?

stites avatar Jan 02 '19 05:01 stites