-- | Streaming types
module Network.GRPC.Spec.RPC.StreamType (
    StreamingType(..)
    -- * Link RPCs to streaming types
  , SupportsStreamingType
  , HasStreamingType(..)
    -- * Handler type definition
  , NextElem(..)
  , Send
  , Recv
  , Positive
  , Negative(..)
  , HandlerRole(..)
  , Handler
    -- * Handler newtype wrappers
  , ServerHandler'(..)
  , ServerHandler
  , ClientHandler'(..)
  , ClientHandler
    -- * Singleton
  , SStreamingType(..)
  , ValidStreamingType(..)
    -- * Hoisting
  , hoistServerHandler
  ) where

-- Borrow protolens 'StreamingType' (but this module is not Protobuf specific)
import Data.ProtoLens.Service.Types (StreamingType(..))

import Data.Kind
import Data.Proxy

import Network.GRPC.Spec.RPC

{-------------------------------------------------------------------------------
  Link RPCs to streaming types
-------------------------------------------------------------------------------}

-- | This RPC supports the given streaming type
--
-- This is a weaker condition than 'HasStreamingType': some (non-Protobuf) RPCs
-- may support more than one streaming type.
class ValidStreamingType styp
   => SupportsStreamingType rpc (styp :: StreamingType)

-- | /The/ streaming type supported by this RPC

-- This is a stronger condition than 'SupportsStreamingType': we associate the
-- RPC with one /specific/ streaming type.
class SupportsStreamingType rpc (RpcStreamingType rpc)
   => HasStreamingType rpc where
  -- | The (single) streaming type supported by this RPC
  type RpcStreamingType rpc :: StreamingType

{-------------------------------------------------------------------------------
  Internal: preliminaries

  'NextElem' does not allow to mark the final streaming element as final /as/ we
  send it; instead, we must use 'NoMoreElems' (which will correspond to an
  additional empty HTTP data frame); similarly, on the input side we cannot
  detect that an element is final as we receive it. This does not matter in the
  vast majority of cases; for the rare case where it does matter, user code can
  simply use the core API instead of the streaming API.

  It /is/ important that we mark the final message as final for /non-streaming/
  cases; some servers get confused when this is not the case. However, this is
  fine: in the non-streaming case we take care of on behalf of the user, and
  don't use 'NextElem' at all.
-------------------------------------------------------------------------------}

-- | Is there a next element in a stream?
data NextElem a = NoNextElem | NextElem !a
  deriving stock (Int -> NextElem a -> ShowS
[NextElem a] -> ShowS
NextElem a -> String
(Int -> NextElem a -> ShowS)
-> (NextElem a -> String)
-> ([NextElem a] -> ShowS)
-> Show (NextElem a)
forall a. Show a => Int -> NextElem a -> ShowS
forall a. Show a => [NextElem a] -> ShowS
forall a. Show a => NextElem a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> NextElem a -> ShowS
showsPrec :: Int -> NextElem a -> ShowS
$cshow :: forall a. Show a => NextElem a -> String
show :: NextElem a -> String
$cshowList :: forall a. Show a => [NextElem a] -> ShowS
showList :: [NextElem a] -> ShowS
Show, NextElem a -> NextElem a -> Bool
(NextElem a -> NextElem a -> Bool)
-> (NextElem a -> NextElem a -> Bool) -> Eq (NextElem a)
forall a. Eq a => NextElem a -> NextElem a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => NextElem a -> NextElem a -> Bool
== :: NextElem a -> NextElem a -> Bool
$c/= :: forall a. Eq a => NextElem a -> NextElem a -> Bool
/= :: NextElem a -> NextElem a -> Bool
Eq, (forall a b. (a -> b) -> NextElem a -> NextElem b)
-> (forall a b. a -> NextElem b -> NextElem a) -> Functor NextElem
forall a b. a -> NextElem b -> NextElem a
forall a b. (a -> b) -> NextElem a -> NextElem b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> NextElem a -> NextElem b
fmap :: forall a b. (a -> b) -> NextElem a -> NextElem b
$c<$ :: forall a b. a -> NextElem b -> NextElem a
<$ :: forall a b. a -> NextElem b -> NextElem a
Functor, (forall m. Monoid m => NextElem m -> m)
-> (forall m a. Monoid m => (a -> m) -> NextElem a -> m)
-> (forall m a. Monoid m => (a -> m) -> NextElem a -> m)
-> (forall a b. (a -> b -> b) -> b -> NextElem a -> b)
-> (forall a b. (a -> b -> b) -> b -> NextElem a -> b)
-> (forall b a. (b -> a -> b) -> b -> NextElem a -> b)
-> (forall b a. (b -> a -> b) -> b -> NextElem a -> b)
-> (forall a. (a -> a -> a) -> NextElem a -> a)
-> (forall a. (a -> a -> a) -> NextElem a -> a)
-> (forall a. NextElem a -> [a])
-> (forall a. NextElem a -> Bool)
-> (forall a. NextElem a -> Int)
-> (forall a. Eq a => a -> NextElem a -> Bool)
-> (forall a. Ord a => NextElem a -> a)
-> (forall a. Ord a => NextElem a -> a)
-> (forall a. Num a => NextElem a -> a)
-> (forall a. Num a => NextElem a -> a)
-> Foldable NextElem
forall a. Eq a => a -> NextElem a -> Bool
forall a. Num a => NextElem a -> a
forall a. Ord a => NextElem a -> a
forall m. Monoid m => NextElem m -> m
forall a. NextElem a -> Bool
forall a. NextElem a -> Int
forall a. NextElem a -> [a]
forall a. (a -> a -> a) -> NextElem a -> a
forall m a. Monoid m => (a -> m) -> NextElem a -> m
forall b a. (b -> a -> b) -> b -> NextElem a -> b
forall a b. (a -> b -> b) -> b -> NextElem a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall m. Monoid m => NextElem m -> m
fold :: forall m. Monoid m => NextElem m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> NextElem a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> NextElem a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> NextElem a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> NextElem a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> NextElem a -> b
foldr :: forall a b. (a -> b -> b) -> b -> NextElem a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> NextElem a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> NextElem a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> NextElem a -> b
foldl :: forall b a. (b -> a -> b) -> b -> NextElem a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> NextElem a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> NextElem a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> NextElem a -> a
foldr1 :: forall a. (a -> a -> a) -> NextElem a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> NextElem a -> a
foldl1 :: forall a. (a -> a -> a) -> NextElem a -> a
$ctoList :: forall a. NextElem a -> [a]
toList :: forall a. NextElem a -> [a]
$cnull :: forall a. NextElem a -> Bool
null :: forall a. NextElem a -> Bool
$clength :: forall a. NextElem a -> Int
length :: forall a. NextElem a -> Int
$celem :: forall a. Eq a => a -> NextElem a -> Bool
elem :: forall a. Eq a => a -> NextElem a -> Bool
$cmaximum :: forall a. Ord a => NextElem a -> a
maximum :: forall a. Ord a => NextElem a -> a
$cminimum :: forall a. Ord a => NextElem a -> a
minimum :: forall a. Ord a => NextElem a -> a
$csum :: forall a. Num a => NextElem a -> a
sum :: forall a. Num a => NextElem a -> a
$cproduct :: forall a. Num a => NextElem a -> a
product :: forall a. Num a => NextElem a -> a
Foldable, Functor NextElem
Foldable NextElem
(Functor NextElem, Foldable NextElem) =>
(forall (f :: * -> *) a b.
 Applicative f =>
 (a -> f b) -> NextElem a -> f (NextElem b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    NextElem (f a) -> f (NextElem a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> NextElem a -> m (NextElem b))
-> (forall (m :: * -> *) a.
    Monad m =>
    NextElem (m a) -> m (NextElem a))
-> Traversable NextElem
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
 Applicative f =>
 (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => NextElem (m a) -> m (NextElem a)
forall (f :: * -> *) a.
Applicative f =>
NextElem (f a) -> f (NextElem a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> NextElem a -> m (NextElem b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> NextElem a -> f (NextElem b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> NextElem a -> f (NextElem b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> NextElem a -> f (NextElem b)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
NextElem (f a) -> f (NextElem a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
NextElem (f a) -> f (NextElem a)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> NextElem a -> m (NextElem b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> NextElem a -> m (NextElem b)
$csequence :: forall (m :: * -> *) a. Monad m => NextElem (m a) -> m (NextElem a)
sequence :: forall (m :: * -> *) a. Monad m => NextElem (m a) -> m (NextElem a)
Traversable)

-- | Send a value
type Send a = NextElem a -> IO ()

-- | Receive a value
--
-- 'Nothing' indicates no more values. Calling this function again after
-- receiving 'Nothing' is a bug.
type Recv a = IO (NextElem a)

-- | Positive use of @a@
type Positive m a b = a -> m b

-- | Negative use of @a@
newtype Negative m a b = Negative {
      forall (m :: * -> *) a b.
Negative m a b -> forall r. (a -> m r) -> m (b, r)
runNegative :: forall r. (a -> m r) -> m (b, r)
    }

{-------------------------------------------------------------------------------
  Handler

  The handler definitions are carefully designed to make the duality between the
  server and the client obvious.
-------------------------------------------------------------------------------}

-- | Handler role
data HandlerRole =
    Server  -- ^ Deal with an incoming request
  | Client  -- ^ Initiate an outgoing request

-- | Type of a handler
type family Handler (r :: HandlerRole) (s :: StreamingType) m (rpc :: k) where
  Handler Server NonStreaming    m rpc = Input rpc -> m (Output rpc)
  Handler Client NonStreaming    m rpc = Input rpc -> m (Output rpc)

  Handler Server ClientStreaming m rpc = Positive m (Recv (Input rpc)) (Output rpc)
  Handler Client ClientStreaming m rpc = Negative m (Send (Input rpc)) (Output rpc)

  Handler Server ServerStreaming m rpc = Input rpc -> Positive m (Send (Output rpc)) ()
  Handler Client ServerStreaming m rpc = Input rpc -> Negative m (Recv (Output rpc)) ()

  Handler Server BiDiStreaming   m rpc = Positive m (Recv (Input rpc), Send (Output rpc)) ()
  Handler Client BiDiStreaming   m rpc = Negative m (Send (Input rpc), Recv (Output rpc)) ()

{-------------------------------------------------------------------------------
  Wrappers
-------------------------------------------------------------------------------}

-- | Wrapper around @Handler Server@ to avoid ambiguous types
data ServerHandler' (styp :: StreamingType) m (rpc :: k) where
  ServerHandler ::
       SupportsStreamingType rpc styp
    => Handler Server styp m rpc
    -> ServerHandler' styp m rpc

-- | Wrapper around @Handler Client@ to avoid ambiguous types
data ClientHandler' (s :: StreamingType) m (rpc :: k) where
  ClientHandler ::
       SupportsStreamingType rpc styp
    => Handler Client styp m rpc
    -> ClientHandler' styp m rpc

-- | Alias for 'ServerHandler'' with the streaming type determined by the @rpc@
type ServerHandler m rpc = ServerHandler' (RpcStreamingType rpc) m rpc

-- | Alias for 'ClientHandler'' with the streaming type determined by the @rpc@
type ClientHandler m rpc = ClientHandler' (RpcStreamingType rpc) m rpc

{-------------------------------------------------------------------------------
  Singleton
-------------------------------------------------------------------------------}

-- | Singleton for 'StreamingType'
data SStreamingType :: StreamingType -> Type where
  SNonStreaming    :: SStreamingType NonStreaming
  SClientStreaming :: SStreamingType ClientStreaming
  SServerStreaming :: SStreamingType ServerStreaming
  SBiDiStreaming   :: SStreamingType BiDiStreaming

-- | Valid streaming types
class ValidStreamingType (styp :: StreamingType) where
  -- | Obtain singleton
  validStreamingType :: Proxy styp -> SStreamingType styp

instance ValidStreamingType NonStreaming    where validStreamingType :: Proxy 'NonStreaming -> SStreamingType 'NonStreaming
validStreamingType Proxy 'NonStreaming
_ = SStreamingType 'NonStreaming
SNonStreaming
instance ValidStreamingType ClientStreaming where validStreamingType :: Proxy 'ClientStreaming -> SStreamingType 'ClientStreaming
validStreamingType Proxy 'ClientStreaming
_ = SStreamingType 'ClientStreaming
SClientStreaming
instance ValidStreamingType ServerStreaming where validStreamingType :: Proxy 'ServerStreaming -> SStreamingType 'ServerStreaming
validStreamingType Proxy 'ServerStreaming
_ = SStreamingType 'ServerStreaming
SServerStreaming
instance ValidStreamingType BiDiStreaming   where validStreamingType :: Proxy 'BiDiStreaming -> SStreamingType 'BiDiStreaming
validStreamingType Proxy 'BiDiStreaming
_ = SStreamingType 'BiDiStreaming
SBiDiStreaming

{-------------------------------------------------------------------------------
  Hoisting
-------------------------------------------------------------------------------}

class HoistServerHandler styp where
  hoistServerHandler' ::
       (forall a. m a -> n a)
    -> ServerHandler' styp m rpc
    -> ServerHandler' styp n rpc

instance HoistServerHandler NonStreaming where
  hoistServerHandler' :: forall {k} (m :: * -> *) (n :: * -> *) (rpc :: k).
(forall a. m a -> n a)
-> ServerHandler' 'NonStreaming m rpc
-> ServerHandler' 'NonStreaming n rpc
hoistServerHandler' forall a. m a -> n a
f (ServerHandler Handler 'Server 'NonStreaming m rpc
h) = Handler 'Server 'NonStreaming n rpc
-> ServerHandler' 'NonStreaming n rpc
forall {k} (rpc :: k) (styp :: StreamingType) (m :: * -> *).
SupportsStreamingType rpc styp =>
Handler 'Server styp m rpc -> ServerHandler' styp m rpc
ServerHandler (Handler 'Server 'NonStreaming n rpc
 -> ServerHandler' 'NonStreaming n rpc)
-> Handler 'Server 'NonStreaming n rpc
-> ServerHandler' 'NonStreaming n rpc
forall a b. (a -> b) -> a -> b
$ \Input rpc
inp ->
      m (Output rpc) -> n (Output rpc)
forall a. m a -> n a
f (m (Output rpc) -> n (Output rpc))
-> m (Output rpc) -> n (Output rpc)
forall a b. (a -> b) -> a -> b
$ Handler 'Server 'NonStreaming m rpc
Input rpc -> m (Output rpc)
h Input rpc
inp

instance HoistServerHandler ClientStreaming where
  hoistServerHandler' :: forall {k} (m :: * -> *) (n :: * -> *) (rpc :: k).
(forall a. m a -> n a)
-> ServerHandler' 'ClientStreaming m rpc
-> ServerHandler' 'ClientStreaming n rpc
hoistServerHandler' forall a. m a -> n a
f (ServerHandler Handler 'Server 'ClientStreaming m rpc
h) = Handler 'Server 'ClientStreaming n rpc
-> ServerHandler' 'ClientStreaming n rpc
forall {k} (rpc :: k) (styp :: StreamingType) (m :: * -> *).
SupportsStreamingType rpc styp =>
Handler 'Server styp m rpc -> ServerHandler' styp m rpc
ServerHandler (Handler 'Server 'ClientStreaming n rpc
 -> ServerHandler' 'ClientStreaming n rpc)
-> Handler 'Server 'ClientStreaming n rpc
-> ServerHandler' 'ClientStreaming n rpc
forall a b. (a -> b) -> a -> b
$ \Recv (Input rpc)
recv ->
      m (Output rpc) -> n (Output rpc)
forall a. m a -> n a
f (m (Output rpc) -> n (Output rpc))
-> m (Output rpc) -> n (Output rpc)
forall a b. (a -> b) -> a -> b
$ Handler 'Server 'ClientStreaming m rpc
Positive m (Recv (Input rpc)) (Output rpc)
h Recv (Input rpc)
recv

instance HoistServerHandler ServerStreaming where
  hoistServerHandler' :: forall {k} (m :: * -> *) (n :: * -> *) (rpc :: k).
(forall a. m a -> n a)
-> ServerHandler' 'ServerStreaming m rpc
-> ServerHandler' 'ServerStreaming n rpc
hoistServerHandler' forall a. m a -> n a
f (ServerHandler Handler 'Server 'ServerStreaming m rpc
h) = Handler 'Server 'ServerStreaming n rpc
-> ServerHandler' 'ServerStreaming n rpc
forall {k} (rpc :: k) (styp :: StreamingType) (m :: * -> *).
SupportsStreamingType rpc styp =>
Handler 'Server styp m rpc -> ServerHandler' styp m rpc
ServerHandler (Handler 'Server 'ServerStreaming n rpc
 -> ServerHandler' 'ServerStreaming n rpc)
-> Handler 'Server 'ServerStreaming n rpc
-> ServerHandler' 'ServerStreaming n rpc
forall a b. (a -> b) -> a -> b
$ \Input rpc
inp Send (Output rpc)
send ->
      m () -> n ()
forall a. m a -> n a
f (m () -> n ()) -> m () -> n ()
forall a b. (a -> b) -> a -> b
$ Handler 'Server 'ServerStreaming m rpc
Input rpc -> Positive m (Send (Output rpc)) ()
h Input rpc
inp Send (Output rpc)
send

instance HoistServerHandler BiDiStreaming where
  hoistServerHandler' :: forall {k} (m :: * -> *) (n :: * -> *) (rpc :: k).
(forall a. m a -> n a)
-> ServerHandler' 'BiDiStreaming m rpc
-> ServerHandler' 'BiDiStreaming n rpc
hoistServerHandler' forall a. m a -> n a
f (ServerHandler Handler 'Server 'BiDiStreaming m rpc
h) = Handler 'Server 'BiDiStreaming n rpc
-> ServerHandler' 'BiDiStreaming n rpc
forall {k} (rpc :: k) (styp :: StreamingType) (m :: * -> *).
SupportsStreamingType rpc styp =>
Handler 'Server styp m rpc -> ServerHandler' styp m rpc
ServerHandler (Handler 'Server 'BiDiStreaming n rpc
 -> ServerHandler' 'BiDiStreaming n rpc)
-> Handler 'Server 'BiDiStreaming n rpc
-> ServerHandler' 'BiDiStreaming n rpc
forall a b. (a -> b) -> a -> b
$ \(Recv (Input rpc)
recv, Send (Output rpc)
send) ->
      m () -> n ()
forall a. m a -> n a
f (m () -> n ()) -> m () -> n ()
forall a b. (a -> b) -> a -> b
$ Handler 'Server 'BiDiStreaming m rpc
Positive m (Recv (Input rpc), Send (Output rpc)) ()
h (Recv (Input rpc)
recv, Send (Output rpc)
send)

-- | Hoist server handler from one monad to another
hoistServerHandler :: forall styp m n rpc.
     ValidStreamingType styp
  => (forall a. m a -> n a)
  -> ServerHandler' styp m rpc
  -> ServerHandler' styp n rpc
hoistServerHandler :: forall {k} (styp :: StreamingType) (m :: * -> *) (n :: * -> *)
       (rpc :: k).
ValidStreamingType styp =>
(forall a. m a -> n a)
-> ServerHandler' styp m rpc -> ServerHandler' styp n rpc
hoistServerHandler forall a. m a -> n a
f =
    case Proxy styp -> SStreamingType styp
forall (styp :: StreamingType).
ValidStreamingType styp =>
Proxy styp -> SStreamingType styp
validStreamingType (forall {k} (t :: k). Proxy t
forall (t :: StreamingType). Proxy t
Proxy @styp) of
      SStreamingType styp
SNonStreaming    -> (forall a. m a -> n a)
-> ServerHandler' styp m rpc -> ServerHandler' styp n rpc
forall {k} (m :: * -> *) (n :: * -> *) (rpc :: k).
(forall a. m a -> n a)
-> ServerHandler' styp m rpc -> ServerHandler' styp n rpc
forall (styp :: StreamingType) {k} (m :: * -> *) (n :: * -> *)
       (rpc :: k).
HoistServerHandler styp =>
(forall a. m a -> n a)
-> ServerHandler' styp m rpc -> ServerHandler' styp n rpc
hoistServerHandler' m a -> n a
forall a. m a -> n a
f
      SStreamingType styp
SClientStreaming -> (forall a. m a -> n a)
-> ServerHandler' styp m rpc -> ServerHandler' styp n rpc
forall {k} (m :: * -> *) (n :: * -> *) (rpc :: k).
(forall a. m a -> n a)
-> ServerHandler' styp m rpc -> ServerHandler' styp n rpc
forall (styp :: StreamingType) {k} (m :: * -> *) (n :: * -> *)
       (rpc :: k).
HoistServerHandler styp =>
(forall a. m a -> n a)
-> ServerHandler' styp m rpc -> ServerHandler' styp n rpc
hoistServerHandler' m a -> n a
forall a. m a -> n a
f
      SStreamingType styp
SServerStreaming -> (forall a. m a -> n a)
-> ServerHandler' styp m rpc -> ServerHandler' styp n rpc
forall {k} (m :: * -> *) (n :: * -> *) (rpc :: k).
(forall a. m a -> n a)
-> ServerHandler' styp m rpc -> ServerHandler' styp n rpc
forall (styp :: StreamingType) {k} (m :: * -> *) (n :: * -> *)
       (rpc :: k).
HoistServerHandler styp =>
(forall a. m a -> n a)
-> ServerHandler' styp m rpc -> ServerHandler' styp n rpc
hoistServerHandler' m a -> n a
forall a. m a -> n a
f
      SStreamingType styp
SBiDiStreaming   -> (forall a. m a -> n a)
-> ServerHandler' styp m rpc -> ServerHandler' styp n rpc
forall {k} (m :: * -> *) (n :: * -> *) (rpc :: k).
(forall a. m a -> n a)
-> ServerHandler' styp m rpc -> ServerHandler' styp n rpc
forall (styp :: StreamingType) {k} (m :: * -> *) (n :: * -> *)
       (rpc :: k).
HoistServerHandler styp =>
(forall a. m a -> n a)
-> ServerHandler' styp m rpc -> ServerHandler' styp n rpc
hoistServerHandler' m a -> n a
forall a. m a -> n a
f