From cc5d30acd2a356be5bc757d18d3068032b85c173 Mon Sep 17 00:00:00 2001 From: Connor Clark Date: Wed, 20 Jul 2016 11:26:53 -0700 Subject: [PATCH] Travis/service generation (#46) * higher bound on clock versions * Added helper module for generated service code --- grpc-haskell.cabal | 2 +- src/Network/GRPC/HighLevel/Generated.hs | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/Network/GRPC/HighLevel/Generated.hs diff --git a/grpc-haskell.cabal b/grpc-haskell.cabal index 69e0b95..c4844c1 100644 --- a/grpc-haskell.cabal +++ b/grpc-haskell.cabal @@ -26,7 +26,7 @@ flag with-examples library build-depends: base ==4.8.* - , clock ==0.6.* + , clock >=0.6.0 && <=0.7.2 , bytestring ==0.10.* , stm == 2.4.* , containers ==0.5.* diff --git a/src/Network/GRPC/HighLevel/Generated.hs b/src/Network/GRPC/HighLevel/Generated.hs new file mode 100644 index 0000000..fca6c8d --- /dev/null +++ b/src/Network/GRPC/HighLevel/Generated.hs @@ -0,0 +1,23 @@ +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE RankNTypes #-} + +module Network.GRPC.HighLevel.Generated where + +import Network.GRPC.HighLevel.Server +import Network.GRPC.LowLevel.Call + +-- | Used at the kind level as a parameter to service definitions +-- generated by the grpc compiler, with the effect of having the +-- field types reduce to the appropriate types for the method types. +data GRPCImpl = ServerImpl | ClientImpl + +-- | GHC does not let us partially apply a type family. However, we +-- can define a type to use as an 'interpreter', and then use this +-- 'interpreter' type fully applied to get the same effect. +type family MkHandler (impl :: GRPCImpl) (methodType :: GRPCMethodType) i o + +type instance MkHandler 'ServerImpl 'Normal i o = ServerHandler i o +type instance MkHandler 'ServerImpl 'ClientStreaming i o = ServerReaderHandler i o +type instance MkHandler 'ServerImpl 'ServerStreaming i o = ServerWriterHandler i o +type instance MkHandler 'ServerImpl 'BiDiStreaming i o = ServerRWHandler i o