mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-26 21:19:43 +01:00
Update Arithmetic
example to use newer proto3-suite
(#102)
Related to https://github.com/awakesecurity/proto3-suite/issues/119
This commit is contained in:
parent
bc155c1a52
commit
595cb6a3bf
2 changed files with 43 additions and 30 deletions
31
examples/tutorial/Arithmetic.hs
generated
31
examples/tutorial/Arithmetic.hs
generated
|
@ -1,6 +1,8 @@
|
||||||
{-# LANGUAGE DeriveGeneric #-}
|
{-# LANGUAGE DeriveGeneric #-}
|
||||||
|
{-# LANGUAGE DeriveAnyClass #-}
|
||||||
{-# LANGUAGE DataKinds #-}
|
{-# LANGUAGE DataKinds #-}
|
||||||
{-# LANGUAGE GADTs #-}
|
{-# LANGUAGE GADTs #-}
|
||||||
|
{-# LANGUAGE TypeApplications #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
|
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
|
||||||
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
|
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
|
||||||
|
@ -9,24 +11,29 @@
|
||||||
-- | Generated by Haskell protocol buffer compiler. DO NOT EDIT!
|
-- | Generated by Haskell protocol buffer compiler. DO NOT EDIT!
|
||||||
module Arithmetic where
|
module Arithmetic where
|
||||||
import qualified Prelude as Hs
|
import qualified Prelude as Hs
|
||||||
import qualified Proto3.Suite.DotProto as HsProtobuf
|
|
||||||
import qualified Proto3.Suite.Types as HsProtobuf
|
|
||||||
import qualified Proto3.Suite.Class as HsProtobuf
|
import qualified Proto3.Suite.Class as HsProtobuf
|
||||||
|
import qualified Proto3.Suite.DotProto as HsProtobuf
|
||||||
import qualified Proto3.Suite.JSONPB as HsJSONPB
|
import qualified Proto3.Suite.JSONPB as HsJSONPB
|
||||||
import Proto3.Suite.JSONPB ((.=), (.:))
|
import Proto3.Suite.JSONPB ((.=), (.:))
|
||||||
|
import qualified Proto3.Suite.Types as HsProtobuf
|
||||||
import qualified Proto3.Wire as HsProtobuf
|
import qualified Proto3.Wire as HsProtobuf
|
||||||
import Control.Applicative ((<*>), (<|>), (<$>))
|
|
||||||
import qualified Control.Applicative as Hs
|
import qualified Control.Applicative as Hs
|
||||||
|
import Control.Applicative ((<*>), (<|>), (<$>))
|
||||||
|
import qualified Control.DeepSeq as Hs
|
||||||
import qualified Control.Monad as Hs
|
import qualified Control.Monad as Hs
|
||||||
import qualified Data.Text.Lazy as Hs (Text)
|
|
||||||
import qualified Data.ByteString as Hs
|
import qualified Data.ByteString as Hs
|
||||||
import qualified Data.String as Hs (fromString)
|
import qualified Data.Coerce as Hs
|
||||||
import qualified Data.Vector as Hs (Vector)
|
|
||||||
import qualified Data.Int as Hs (Int16, Int32, Int64)
|
import qualified Data.Int as Hs (Int16, Int32, Int64)
|
||||||
import qualified Data.Word as Hs (Word16, Word32, Word64)
|
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.Proxy as Proxy
|
||||||
import qualified GHC.Generics as Hs
|
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.Enum as Hs
|
||||||
|
import qualified GHC.Generics as Hs
|
||||||
|
import qualified Unsafe.Coerce as Hs
|
||||||
import Network.GRPC.HighLevel.Generated as HsGRPC
|
import Network.GRPC.HighLevel.Generated as HsGRPC
|
||||||
import Network.GRPC.HighLevel.Client as HsGRPC
|
import Network.GRPC.HighLevel.Client as HsGRPC
|
||||||
import Network.GRPC.HighLevel.Server as HsGRPC hiding (serverLoop)
|
import Network.GRPC.HighLevel.Server as HsGRPC hiding (serverLoop)
|
||||||
|
@ -87,11 +94,13 @@ arithmeticClient client
|
||||||
(HsGRPC.MethodName "/arithmetic.Arithmetic/RunningSum")))
|
(HsGRPC.MethodName "/arithmetic.Arithmetic/RunningSum")))
|
||||||
|
|
||||||
data TwoInts = TwoInts{twoIntsX :: Hs.Int32, twoIntsY :: Hs.Int32}
|
data TwoInts = TwoInts{twoIntsX :: Hs.Int32, twoIntsY :: Hs.Int32}
|
||||||
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
|
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic, Hs.NFData)
|
||||||
|
|
||||||
instance HsProtobuf.Named TwoInts where
|
instance HsProtobuf.Named TwoInts where
|
||||||
nameOf _ = (Hs.fromString "TwoInts")
|
nameOf _ = (Hs.fromString "TwoInts")
|
||||||
|
|
||||||
|
instance HsProtobuf.HasDefault TwoInts
|
||||||
|
|
||||||
instance HsProtobuf.Message TwoInts where
|
instance HsProtobuf.Message TwoInts where
|
||||||
encodeMessage _ TwoInts{twoIntsX = twoIntsX, twoIntsY = twoIntsY}
|
encodeMessage _ TwoInts{twoIntsX = twoIntsX, twoIntsY = twoIntsY}
|
||||||
= (Hs.mconcat
|
= (Hs.mconcat
|
||||||
|
@ -155,11 +164,13 @@ instance HsJSONPB.ToSchema TwoInts where
|
||||||
[("x", twoIntsX), ("y", twoIntsY)]}})
|
[("x", twoIntsX), ("y", twoIntsY)]}})
|
||||||
|
|
||||||
data OneInt = OneInt{oneIntResult :: Hs.Int32}
|
data OneInt = OneInt{oneIntResult :: Hs.Int32}
|
||||||
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic)
|
deriving (Hs.Show, Hs.Eq, Hs.Ord, Hs.Generic, Hs.NFData)
|
||||||
|
|
||||||
instance HsProtobuf.Named OneInt where
|
instance HsProtobuf.Named OneInt where
|
||||||
nameOf _ = (Hs.fromString "OneInt")
|
nameOf _ = (Hs.fromString "OneInt")
|
||||||
|
|
||||||
|
instance HsProtobuf.HasDefault OneInt
|
||||||
|
|
||||||
instance HsProtobuf.Message OneInt where
|
instance HsProtobuf.Message OneInt where
|
||||||
encodeMessage _ OneInt{oneIntResult = oneIntResult}
|
encodeMessage _ OneInt{oneIntResult = oneIntResult}
|
||||||
= (Hs.mconcat
|
= (Hs.mconcat
|
||||||
|
|
|
@ -122,6 +122,7 @@ executable arithmetic-server
|
||||||
, async
|
, async
|
||||||
, bytestring == 0.10.*
|
, bytestring == 0.10.*
|
||||||
, containers >=0.5 && <0.7
|
, containers >=0.5 && <0.7
|
||||||
|
, deepseq
|
||||||
, grpc-haskell
|
, grpc-haskell
|
||||||
, grpc-haskell-core
|
, grpc-haskell-core
|
||||||
, optparse-generic
|
, optparse-generic
|
||||||
|
@ -145,6 +146,7 @@ executable arithmetic-client
|
||||||
, async
|
, async
|
||||||
, bytestring == 0.10.*
|
, bytestring == 0.10.*
|
||||||
, containers >=0.5 && <0.7
|
, containers >=0.5 && <0.7
|
||||||
|
, deepseq
|
||||||
, grpc-haskell
|
, grpc-haskell
|
||||||
, grpc-haskell-core
|
, grpc-haskell-core
|
||||||
, optparse-generic
|
, optparse-generic
|
||||||
|
|
Loading…
Reference in a new issue