content: {-# LANGUAGE DataKinds #-}
  {-# LANGUAGE DeriveAnyClass #-}
  {-# LANGUAGE DeriveGeneric #-}
  {-# LANGUAGE GADTs #-}
  {-# LANGUAGE OverloadedStrings #-}
  {-# LANGUAGE TypeApplications #-}
  {-# OPTIONS_GHC -fno-warn-missing-export-lists #-}
  {-# OPTIONS_GHC -fno-warn-name-shadowing #-}
  {-# OPTIONS_GHC -fno-warn-unused-imports #-}
  {-# OPTIONS_GHC -fno-warn-unused-matches #-}
  
  -- | Generated by Haskell protocol buffer compiler. DO NOT EDIT!
  module Echo where
  
  import Control.Applicative ((<$>), (<*>), (<|>))
  import qualified Control.Applicative as Hs
  import qualified Control.DeepSeq as Hs
  import qualified Control.Monad as Hs
  import qualified Data.ByteString as Hs
  import qualified Data.Coerce as Hs
  import qualified Data.Int as Hs (Int16, Int32, Int64)
  import qualified Data.List.NonEmpty as Hs (NonEmpty (..))
  import qualified Data.Map as Hs (Map, mapKeysMonotonic)
  import qualified Data.Proxy as Proxy
  import qualified Data.String as Hs (fromString)
  import qualified Data.Text.Lazy as Hs (Text)
  import qualified Data.Vector as Hs (Vector)
  import qualified Data.Word as Hs (Word16, Word32, Word64)
  import qualified GHC.Enum as Hs
  import qualified GHC.Generics as Hs
  import qualified Google.Protobuf.Wrappers.Polymorphic as HsProtobuf (
    Wrapped (..),
   )
  import Network.GRPC.HighLevel.Client as HsGRPC
  import Network.GRPC.HighLevel.Generated as HsGRPC
  import Network.GRPC.HighLevel.Server as HsGRPC hiding (serverLoop)
  import Network.GRPC.HighLevel.Server.Unregistered as HsGRPC (
    serverLoop,
   )
  import qualified Proto3.Suite.Class as HsProtobuf
  import qualified Proto3.Suite.DotProto as HsProtobufAST
  import Proto3.Suite.JSONPB ((.:), (.=))
  import qualified Proto3.Suite.JSONPB as HsJSONPB
  import qualified Proto3.Suite.Types as HsProtobuf
  import qualified Proto3.Wire as HsProtobuf
  import qualified Proto3.Wire.Decode as HsProtobuf (
    Parser,
    RawField,
   )
  import qualified Unsafe.Coerce as Hs
  import qualified Prelude as Hs
  
  data Echo request response = Echo
    { echoDoEcho ::
        request 'HsGRPC.Normal Echo.EchoRequest Echo.EchoResponse ->
        Hs.IO (response 'HsGRPC.Normal Echo.EchoResponse)
    }
    deriving (Hs.Generic)
  
  echoServer ::
    Echo HsGRPC.ServerRequest HsGRPC.ServerResponse ->
    HsGRPC.ServiceOptions ->
    Hs.IO ()
  echoServer
    Echo{echoDoEcho = echoDoEcho}
    ( ServiceOptions
        serverHost
        serverPort
        useCompression
        userAgentPrefix
        userAgentSuffix
        initialMetadata
        sslConfig
        logger
        serverMaxReceiveMessageLength
        serverMaxMetadataSize
      ) =
      ( HsGRPC.serverLoop
          HsGRPC.defaultOptions
            { HsGRPC.optNormalHandlers =
                [ ( HsGRPC.UnaryHandler
                      (HsGRPC.MethodName "/echo.Echo/DoEcho")
                      (HsGRPC.convertGeneratedServerHandler echoDoEcho)
                  )
                ]
            , HsGRPC.optClientStreamHandlers = []
            , HsGRPC.optServerStreamHandlers = []
            , HsGRPC.optBiDiStreamHandlers = []
            , optServerHost = serverHost
            , optServerPort = serverPort
            , optUseCompression = useCompression
            , optUserAgentPrefix = userAgentPrefix
            , optUserAgentSuffix = userAgentSuffix
            , optInitialMetadata = initialMetadata
            , optSSLConfig = sslConfig
            , optLogger = logger
            , optMaxReceiveMessageLength = serverMaxReceiveMessageLength
            , optMaxMetadataSize = serverMaxMetadataSize
            }
      )
  
  echoClient ::
    HsGRPC.Client ->
    Hs.IO (Echo HsGRPC.ClientRequest HsGRPC.ClientResult)
  echoClient client =
    (Hs.pure Echo)
      <*> ( (Hs.pure (HsGRPC.clientRequest client))
              <*> ( HsGRPC.clientRegisterMethod
                      client
                      (HsGRPC.MethodName "/echo.Echo/DoEcho")
                  )
          )
  
  newtype EchoRequest = EchoRequest {echoRequestMessage :: Hs.Text}
    deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
  
  instance Hs.NFData EchoRequest
  
  instance HsProtobuf.Named EchoRequest where
    nameOf _ = (Hs.fromString "EchoRequest")
  
  instance HsProtobuf.HasDefault EchoRequest
  
  instance HsProtobuf.Message EchoRequest where
    encodeMessage
      _
      EchoRequest{echoRequestMessage = echoRequestMessage} =
        ( Hs.mconcat
            [ ( HsProtobuf.encodeMessageField
                  (HsProtobuf.FieldNumber 1)
                  ( Hs.coerce @(Hs.Text) @(HsProtobuf.String Hs.Text)
                      (echoRequestMessage)
                  )
              )
            ]
        )
    decodeMessage _ =
      (Hs.pure EchoRequest)
        <*> ( HsProtobuf.coerceOver @(HsProtobuf.String Hs.Text) @(Hs.Text)
                ( HsProtobuf.at
                    HsProtobuf.decodeMessageField
                    (HsProtobuf.FieldNumber 1)
                )
            )
    dotProto _ =
      [ ( HsProtobufAST.DotProtoField
            (HsProtobuf.FieldNumber 1)
            (HsProtobufAST.Prim HsProtobufAST.String)
            (HsProtobufAST.Single "message")
            []
            ""
        )
      ]
  
  instance HsJSONPB.ToJSONPB EchoRequest where
    toJSONPB (EchoRequest f1) =
      ( HsJSONPB.object
          [ "message"
              .= (Hs.coerce @(Hs.Text) @(HsProtobuf.String Hs.Text) (f1))
          ]
      )
    toEncodingPB (EchoRequest f1) =
      ( HsJSONPB.pairs
          [ "message"
              .= (Hs.coerce @(Hs.Text) @(HsProtobuf.String Hs.Text) (f1))
          ]
      )
  
  instance HsJSONPB.FromJSONPB EchoRequest where
    parseJSONPB =
      ( HsJSONPB.withObject
          "EchoRequest"
          ( \obj ->
              (Hs.pure EchoRequest)
                <*> ( HsProtobuf.coerceOver @(HsProtobuf.String Hs.Text) @(Hs.Text)
                        (obj .: "message")
                    )
          )
      )
  
  instance HsJSONPB.ToJSON EchoRequest where
    toJSON = HsJSONPB.toAesonValue
    toEncoding = HsJSONPB.toAesonEncoding
  
  instance HsJSONPB.FromJSON EchoRequest where
    parseJSON = HsJSONPB.parseJSONPB
  
  instance HsJSONPB.ToSchema EchoRequest where
    declareNamedSchema _ =
      do
        let declare_message = HsJSONPB.declareSchemaRef
        echoRequestMessage <- declare_message Proxy.Proxy
        let _ =
              Hs.pure EchoRequest
                <*> ( HsProtobuf.coerceOver @(HsProtobuf.String Hs.Text) @(Hs.Text)
                        (HsJSONPB.asProxy declare_message)
                    )
        Hs.return
          ( HsJSONPB.NamedSchema
              { HsJSONPB._namedSchemaName =
                  Hs.Just "EchoRequest"
              , HsJSONPB._namedSchemaSchema =
                  Hs.mempty
                    { HsJSONPB._schemaParamSchema =
                        Hs.mempty
                          { HsJSONPB._paramSchemaType =
                              Hs.Just HsJSONPB.SwaggerObject
                          }
                    , HsJSONPB._schemaProperties =
                        HsJSONPB.insOrdFromList
                          [("message", echoRequestMessage)]
                    }
              }
          )
  
  newtype EchoResponse = EchoResponse {echoResponseMessage :: Hs.Text}
    deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
  
  instance Hs.NFData EchoResponse
  
  instance HsProtobuf.Named EchoResponse where
    nameOf _ = (Hs.fromString "EchoResponse")
  
  instance HsProtobuf.HasDefault EchoResponse
  
  instance HsProtobuf.Message EchoResponse where
    encodeMessage
      _
      EchoResponse{echoResponseMessage = echoResponseMessage} =
        ( Hs.mconcat
            [ ( HsProtobuf.encodeMessageField
                  (HsProtobuf.FieldNumber 1)
                  ( Hs.coerce @(Hs.Text) @(HsProtobuf.String Hs.Text)
                      (echoResponseMessage)
                  )
              )
            ]
        )
    decodeMessage _ =
      (Hs.pure EchoResponse)
        <*> ( HsProtobuf.coerceOver @(HsProtobuf.String Hs.Text) @(Hs.Text)
                ( HsProtobuf.at
                    HsProtobuf.decodeMessageField
                    (HsProtobuf.FieldNumber 1)
                )
            )
    dotProto _ =
      [ ( HsProtobufAST.DotProtoField
            (HsProtobuf.FieldNumber 1)
            (HsProtobufAST.Prim HsProtobufAST.String)
            (HsProtobufAST.Single "message")
            []
            ""
        )
      ]
  
  instance HsJSONPB.ToJSONPB EchoResponse where
    toJSONPB (EchoResponse f1) =
      ( HsJSONPB.object
          [ "message"
              .= (Hs.coerce @(Hs.Text) @(HsProtobuf.String Hs.Text) (f1))
          ]
      )
    toEncodingPB (EchoResponse f1) =
      ( HsJSONPB.pairs
          [ "message"
              .= (Hs.coerce @(Hs.Text) @(HsProtobuf.String Hs.Text) (f1))
          ]
      )
  
  instance HsJSONPB.FromJSONPB EchoResponse where
    parseJSONPB =
      ( HsJSONPB.withObject
          "EchoResponse"
          ( \obj ->
              (Hs.pure EchoResponse)
                <*> ( HsProtobuf.coerceOver @(HsProtobuf.String Hs.Text) @(Hs.Text)
                        (obj .: "message")
                    )
          )
      )
  
  instance HsJSONPB.ToJSON EchoResponse where
    toJSON = HsJSONPB.toAesonValue
    toEncoding = HsJSONPB.toAesonEncoding
  
  instance HsJSONPB.FromJSON EchoResponse where
    parseJSON = HsJSONPB.parseJSONPB
  
  instance HsJSONPB.ToSchema EchoResponse where
    declareNamedSchema _ =
      do
        let declare_message = HsJSONPB.declareSchemaRef
        echoResponseMessage <- declare_message Proxy.Proxy
        let _ =
              Hs.pure EchoResponse
                <*> ( HsProtobuf.coerceOver @(HsProtobuf.String Hs.Text) @(Hs.Text)
                        (HsJSONPB.asProxy declare_message)
                    )
        Hs.return
          ( HsJSONPB.NamedSchema
              { HsJSONPB._namedSchemaName =
                  Hs.Just "EchoResponse"
              , HsJSONPB._namedSchemaSchema =
                  Hs.mempty
                    { HsJSONPB._schemaParamSchema =
                        Hs.mempty
                          { HsJSONPB._paramSchemaType =
                              Hs.Just HsJSONPB.SwaggerObject
                          }
                    , HsJSONPB._schemaProperties =
                        HsJSONPB.insOrdFromList
                          [("message", echoResponseMessage)]
                    }
              }
          )
  