Giter VIP home page Giter VIP logo

Comments (1)

robrix avatar robrix commented on June 16, 2024 1

It's a bit complicated:

As it stands, no, that's beyond the library's expressiveness for scoped effects, where actions are restricted to having the same type as any actions they contain.

On the other hand, there's nothing stopping one from writing a handler with the desired type. I believe the Church-encoded Error carrier's runError handler could be specialized to provide something like this, with a little wrangling.

Or you could in principle do something like define a Try effect which wraps a universally quantified action of type m' which is like m but Has (Throw e) sig m'. There has to be some way of relating m' to m for this to work, e.g. for m' to be t m where t is some monad transformer such that t m is a Throw e-carrier. I have no idea if this could be made ergonomic; I conjecture not; in particular if the t m route is unavoidable, it's going to pin down the relationship between the two carriers, which is already pretty sus. Anyway, this method is not quite what you're asking for, since it works by only providing Throw within the relevant context, but it's at least similar.

I can't think of any other way of doing this. Every effect system and language (e.g. Frank supports this, but only via handlers, which means it runs into the non-scoped effect problems pretty much immediately, cf Effect Handlers in Scope among others) I can think of disallows effect polymorphism if only because you get so much without it, but it's essentially the same problem as wanting an indexed Reader for e.g. contexts represented as length-indexed vectors for use with de Bruijn-indexed variables—clearly doable, not so clearly ergonomic, at least in Haskell.

Note that Nick Wu & Tom Schrijvers have a couple of papers whose names I forget describing effect systems which IIRC do allow for effect polymorphism, but I'm not aware of any implementation, Haskell or otherwise, which allows for effect composition as well.

My ideal here would be to provide polymorphism with essentially the signature you've given, or similarly the signatures for shift and reset in Cont, i.e. for effects to be able to provide operations which change their parameters. But as it stands, there's no way even to express this with the type of Catch, which only describes the error being caught and the error being returned, and never the error being thrown.

from fused-effects.

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.