mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-06-29 07:58:35 +02:00
24 lines
1.0 KiB
Haskell
24 lines
1.0 KiB
Haskell
|
{-# 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
|