-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add something like Polysemy's Members
#52
Comments
Yeah, I considered it. I didn't yet since not having it avoids unnecessary bikeshedding whether But maybe that's a weak argument. |
I think that once you get to 5+ effects on the stack, the second way becomes much more readable. Loving the library btw, managed to port pat.hs from |
Thanks 🙇
That's a good point. You've convinced me ;) I have a plan of porting a big application that uses a lot of effects from the mtl style once There's one more thing though. For some reason ghci 9.2.1 started printing such signatures in a very ugly way:
But previous releases print it normally:
I'd consider that a regression though, I'll make a ticket on the GHC bug tracker. |
Bikeshedding time.
|
I am against just using the flipped version |
Fixed by 938550b. BTW, the GHC ticket is here: https://gitlab.haskell.org/ghc/ghc/-/issues/20974 It'll be fixed, so everything works out 👍 |
Sadly I have to remove this (see #101 for explanation) for the sake of good long-term user experience in terms of compilation times. |
Maybe we could re-open this issue then and mark it as blocked by the GHC issue? Just to keep track of it and signal to users that we actually want this feature... |
Fair enough. I decided to deprecate it for now and only remove it in 3.0.0.0 to ease the transition period for people who were writing type signatures with it. |
Thank you @arybczak for shedding light on this flaw. I wonder if by chance we could have |
That maybe could work, but compiler plugins come with their own set of problems, so I'm reluctant to use them for this. |
We could try manually generating cases of the type family (up to some limit) type family Effs effs es :: Constraint where
Effs '[] es = ()
Effs '[e1, e2] es = (e1 :> es, e2 :> es)
Effs '[e1, e2, e3] es = (e1 :> es, e2 :> es, e3 :> es)
Effs '[... en] es = (... en :> es) This is used in fastsum. |
That would be much better than recursive definition, but there's still some overhead when compared to direct usage of Also, I just realized that |
I'm thinking in order to get support for this, it would have to probably be specifically added to the compiler plugin too, right? I don't think we can expect GHC to evaluate type families producing constraints in every case in order to find redundant ones. (It's probably not even possible in some cases where the constraints produced depend on a type parameter.) |
Ok, so I benchmarked it by measuring compilation times and Core sizes of 50 functions that look like this: testN :: [E1, ..., E21] :>> es => Eff es ()
testN = do
send E21
...
send E1 Here are results for 50 functions that use 11 effects each:
So a slowdown of 8% and 16% respectively. and for 50 functions that use 21 effects each:
A slowdown of 16% and 46% respectively. So: Pros:
Cons:
I can't say I'm a fan of leaving this in. |
I'm porting a codebase from cleff to effectful and am running into deprecated
Is there some analog to |
What about |
Thanks, that did the trick! I didn't know about the The conversion from cleff went well. I liked cleff, but the compiler plugin no longer works on current ghc. |
For quickly defining the possible effects, Polysemy has the Members type family. This can of course be implemented in effectful, something like this:
Or maybe another type operator like
::>
?Or is there any particular reason it's not a thing yet?
The text was updated successfully, but these errors were encountered: