GithubHelp home page GithubHelp logo

except effect about monad-classes HOT 4 CLOSED

ibotty avatar ibotty commented on August 19, 2024
except effect

from monad-classes.

Comments (4)

UnkindPartition avatar UnkindPartition commented on August 19, 2024

Throwing exceptions is done using throw. For handling exceptions there are two options:

  • runExcept from C.M.C.Run, which is the same as runExceptT (but with a different name)
  • let them reach the IO layer and turn them into ordinary runtime exceptions

The situation with functions like catch and withExcept is subtle. The user might get an impression that she's just mapping exceptions, but in reality she's also moving them from one layer to another, which may affect how exceptions interact with other effects.

So yes, my intention was to use runExcept to make the semantics a bit more explicit. But if you have compelling use cases for these other functions, I am open to reconsider.

from monad-classes.

ibotty avatar ibotty commented on August 19, 2024

i am frequently using withExceptT to map from one type of exception to another.
say given an ExceptT m InternalException a i want to wrap it in a sum type data MyException = InternalE InternalException | SomeOtherExceptionwithwithExceptT InternalE`.

what do you think about making catch and a type changing mapException part of the type class? that way it won't move from one layer to another. of course the order of layers might still change.

btw. in extensible-effects the moral equivalent to withExcept is called rethrowExc. perhaps that makes it more clean.

from monad-classes.

UnkindPartition avatar UnkindPartition commented on August 19, 2024

Making mapExcept part of a type class addresses my concerns. Only I'd like it to be a separate class (cf. MonadReader/MonadLocal). MonadMapExcept? One of the reasons to do so is that it'll require an additional MFunctor constraint, if I'm not mistaken.

Same for catch. I guess you'll need MonadTransControl to lift it automatically.

from monad-classes.

ibotty avatar ibotty commented on August 19, 2024

I am aware that catch and thus withExcept need additional constraints. I'll send a pull request within that week i suppose.

Thanks for being supportive.

from monad-classes.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.