Comments (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)
- Unversioned documentation links all point to master HOT 3
- throwError law is undocumented
- Add Accum effect HOT 4
- Regression with Error in fused effects 1.1 HOT 7
- Carriers should preserve MonadResource HOT 3
- fused-effects 1.1 performance degradation? HOT 6
- TraceText Effect HOT 3
- MonadBaseControl for Labelled Effects HOT 1
- Add instances of MonadCatch, MonadThrow, MonadMask, where possible? HOT 6
- This code for solving prime numbers is about 6 times slower than primes HOT 2
- test suite build failure on Stackage Nightly (GHC 9.0.1) HOT 2
- Why are we slower than mtl? HOT 7
- Difficulty (impossibility?) to wrap `reactive-banana` as effect HOT 2
- Export effect constructors from separate modules
- GHC 9.4.1 compatibility
- Write infodump on how to define algebras
- Accum effect mixed with other effects duplicates accumulated monoidal value HOT 4
- The README makes an unclear statement about visible type applications relating to running effects HOT 1
- Update dependency bounds to support GHC 9.8 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fused-effects.