GithubHelp home page GithubHelp logo

Use the exceptions package about rest HOT 3 CLOSED

silkapp avatar silkapp commented on June 18, 2024
Use the exceptions package

from rest.

Comments (3)

hesselink avatar hesselink commented on June 18, 2024

We need the error type in the type signature, to be able to say things about it (like the serialization formats supported). With exceptions like those in exceptions, you don't get this: the possible exception types are hidden. So I don't think this is possible to do easily.

from rest.

dpwiz avatar dpwiz commented on June 18, 2024

Well... Apparently, exceptions provide an instances for ErrorT m and other transformers so the only monad required to provide Throw/Cath/Mask instances is GenHandler m. So this task is pretty low-priority and needs relevant use cases first. Maybe i'll hit them in my project soon.

from rest.

hesselink avatar hesselink commented on June 18, 2024

I thought you wanted to remove the ErrorT layer? To be honest, I don't quite see how this would work, or why it would be useful. The GenHandler type now looks like this:

data GenHandler m f where
  GenHandler ::
    { dictionary :: Dict h p i o e
    , handler    :: Env h p i -> ErrorT (Reason e) m (Apply f o)
    , secure     :: Bool
    } -> GenHandler m f

As you can see, the e error type in the handler field is the same as the e in the dictionary field. This is needed to make sure errors have the right serialization formats, can be documented, etc. So if we change it to something like this:

  GenHandler ::
    { dictionary :: Dict h p i o e
    , handler    :: MonadThrow m => Env h p i -> m (Apply f o)
    , secure     :: Bool
    } -> GenHandler m f

Now the e is completely gone from handler, we can throw anything, but we can't document it, serialize it, or even get a hold of it when running the handler.

I'll close the ticket for now, but feel free to reopen it if you have an actual problem/use case related to this.

from rest.

Related Issues (20)

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.