Conversation
This is step 0 in the process of converting galley to effects. We introduce a phantom type variable `r` in the `Galley` monad, which will later be used for the effect row.
mdimjasevic
left a comment
There was a problem hiding this comment.
This is great!
There is just one comment I left next to what seems like an accidental sed replacement.
| \\n\ | ||
| \Rationale: there are two services in the backend that need to keep their status in sync: galley (teams),\n\ | ||
| \and spar (SSO). Galley keeps track of team features. If galley creates an idp, the feature flag is\n\ | ||
| \and spar (SSO). Galley r keeps track of team features. If galley creates an idp, the feature flag is\n\ |
There was a problem hiding this comment.
I suppose this is an undesired consequence of using sed.
|
Overall this looks like a good plan! I'm a bit concerned about this Is concurrency a necessary feature of |
|
To follow up on my previous comment, I spent some time going through Things that use unliftIO:
In short, I see nothing here that couldn't just run new threads in Before moving forward with polysemization, I'd suggest refactoring these uses out to just do |
|
Thanks @isovector for looking at this!
The actions it supports are precisely those in the last section of
I agree that concurrency (parallelism, really) in Galley is just for performance, and that the
It would, and it's a good idea in principle, I'm just not sure how to do this in practice. I understand the overall principle on what makes a good effect, and why having an effect like For example, consider the Data functions. Right now some of them have a constraint for So I would still go with the current PR as the first step. What do you think? |
I think this is the crux of my concern. In 61fe4de the old We took the other direction in Spar. Rather than futz with wire-server/services/spar/src/Spar/Data.hs Lines 53 to 63 in 61fe4de and turned that into an effect: wire-server/services/spar/src/Spar/Sem/IdP.hs Lines 27 to 31 in 6291a90 which gets interpreted back directly into wire-server/services/spar/src/Spar/Sem/IdP/Cassandra.hs Lines 9 to 21 in 6291a90 and finally has an interpretation of wire-server/services/spar/src/Spar/Sem/SAMLUserStore/Cassandra.hs Lines 32 to 42 in 6291a90 I'd suggest this direction is going to be a smoother move. Rather than introducing a bunch of temporary, "bad" effects, why not just implement the effects we want from the get go and save some engineering effort. I'd be more than happy to help hammer out any technical difficulties in moving this direction if you're interested in pairing! |
|
Closing in favour of #1881. |
Background
This is the first in a series of PRs with the goal of converting our single Galley monad stack into a polysemy Sem monad. The plan is to do this incrementally in a way that is very unlikely to break anything.
Explanation of the changes
(Please read this before reviewing, then review commits individually.)
One of the main technical difficulties with using
Seminstead of our mtl-basedGalleymonad is the lack of instances for ad-hoc type classes likeMonadCatchandMonadUnliftIO. Although it might be possible to work around the first one with some tricks, the second is just not well-defined at all for "open"Semmonads (i.e.Sem rmonads whereris only required to satisfy someMemberconstraints).This PR is an initial step towards removing such problematic higher-order constraints, and it accomplishes the following:
rto theGalleymonad type. This will eventually be used to hold theSemeffects, but at the moment is just a phantom type variable.Datamodule.Concurrencyeffect. This will eventually be used to implement some async primitives as effect methods, but for now it's just there so that we can keep track of which functions needMonadUnliftIO.MonadUnliftIOwith uses of some ad-hoc functions, and removes theMonadUnliftIOinstance ofGalley. These functions will later be implemented using theConcurrencyeffect.Datafunctions in integration tests.Note that at this point we are only using
polysemyfor itsMemberconstraint and theEffectRowkind. We are still not making use ofSemin any way, and we won't for some time.Next steps
A follow-up PR will deal with
MonadCatchand friends in a similar way, so we will never have to define dubious instances forSem. A corresponding placeholder effect will be introduced.Later on, we will start making use of error and input effects, still without actually having to use
Sem.Once most of the code is equipped with the correct constraints, we can start reimplementing Galley in terms of Sem, and perhaps even make it a type synonym.
After that, we will introduce more high level effects (db, brig-intra, gundeck-intra, etc...) and refactor accordingly.
Checklist
changelog.d.