Seeking advice on using generics with services in Effect Typescript library

Hey! Can I get some help with services with generics? I've got repro here: https://effect.website/play/#063b7b75a90d

I want to put core synchronous algebra on generic point into the service PointTypeAlgebra and some side-effectful and asynchronous operations that can produce and consume those generic points PointTypeService. My entire app will be defined in terms of generic points and the app shouldn't peek at the specific point type and should be agnostic from it.

At runtime or build time I determine which of the two layer implementations to provide for that algebra and effectful operations, which depend on points specific to those implementations. Each of the layer implementations is implemented in terms of the internal point for each of those layers (layerSpecific1 and layerSpecific2) and each layer would be consistent.

In my main I have to do a cast from layer of specific point to layer of generic point, since the entire app is done in terms of generic point. Is it a sensible approach? I'm kinda uncomfortable with the cast like that, but I'm not sure of any better way than that. Does anyone know of any better approach where data and operations are dependent on each other?
Was this page helpful?