Skip to content

Which throwM to implement MonadThrow? #31

@istathar

Description

@istathar

Ideally, you'd be able to

 import Control.Exception.Safe

and be on your way; "drop-in replacement" or whatever. To that end, safe-exceptions re-exports MonadThrow, which is nice. It does not, however, export the throwM method of MonadThrow, instead having its own throwM function (which is just a convenience alias for throw).

The catch is that if you need to implement your own instance of MonadThrow,

instance MonadThrow Program where
      throwM = liftIO . throwM

you end up with

src/Program.hs:108:5-10: error:
    ‘throwM’ is not a (visible) method of class ‘MonadThrow’
    |
108 |     throwM = liftIO . throwM
    |     ^^^^^^

which is a tad inconvenient. I was about to send you a pull request changing the export to MonadThrow(throwM) when I realized that there is already a throwM and its not the class method. So I'm not sure what to do here. Having to do

import Control.Exception.Safe hiding (throwM)
import Control.Monad.Catch (MonadThrow(throwM))

seems likely to not be what you had in mind. How can I help put this right?

AfC

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions