Closed riz0id closed 1 year ago
This has also bit me and I've considered doing the same thing but never got around to this. Is there any way a pattern synonym could be exported instead that would construct / match on the constructor that we could name with the prefix "unsafe"?
On second thought, it would be better to keep the constructor for GRPC
hidden and instead export a version of initGrpc
that returns a GRPC
value. This is what withGRPC
does currently and would expose a way of obtaining a GRPC
value that doesn't break the any assumptions behind how GRPC
is used internally.
Yeah, I like that idea better too.
I agree w/ the latter proposed solution, and I too have wanted to do something along these lines for a while. Thanks, @riz0id!
@riz0id could you update the PR description for posterity?
This PR exports the constructor
GRPC
datatype.gRPC-haskell
uses this datatype to witness proof that gRPC server has been started. AGRPC
value can only be obtained via thewithGRPC
function. It seems like this was done to prevent aGRPC
value from being created without first initializing the gRPC server.Disallowing access to the constructor for
GRPC
makes sense, but it also makes it impossible write custom bracketing functions for initialization and cleanup of gRPC servers withinitGrpc
andgrpcShutdown
.Having access to this constructor would be very helpful when writing tests that need to create a gRPC server for the duration of the test with
Test.Tasty.withResource
. Otherwise, the only option I have to obtain aGRPC
value (as far as I know) is something like: