diff --git a/README.md b/README.md index 5f973cc..c67493b 100644 --- a/README.md +++ b/README.md @@ -9,29 +9,11 @@ Installation **The current version of this library requires gRPC version 1.2.0. Newer versions may work but have not been tested.** -Run the following command from the root of this repository to install the -`compile-proto-file` executable: - -```bash -$ nix-env -iA grpc-haskell -f release.nix -``` - Usage ----- There is a tutorial [here](examples/tutorial/TUTORIAL.md) -```bash -$ compile-proto-file --help -Dumps a compiled .proto file to stdout - -Usage: compile-proto-file --proto FILEPATH - -Available options: - -h,--help Show this help text - --proto FILEPATH Path to input .proto file -``` - Building and testing -------------------- diff --git a/examples/echo/echo-hs/Echo.hs b/examples/echo/echo-hs/Echo.hs index 37e178a..f7cf0cf 100644 --- a/examples/echo/echo-hs/Echo.hs +++ b/examples/echo/echo-hs/Echo.hs @@ -12,7 +12,7 @@ import qualified Proto3.Suite.Types as HsProtobuf import qualified Proto3.Suite.Class as HsProtobuf import qualified Proto3.Wire as HsProtobuf import Control.Applicative ((<*>), (<|>)) -import qualified Data.Text as Hs (Text) +import qualified Data.Text.Lazy as Hs (Text) import qualified Data.ByteString as Hs import qualified Data.String as Hs (fromString) import qualified Data.Vector as Hs (Vector) diff --git a/examples/echo/echo-hs/EchoClient.hs b/examples/echo/echo-hs/EchoClient.hs index 4757758..268f86b 100644 --- a/examples/echo/echo-hs/EchoClient.hs +++ b/examples/echo/echo-hs/EchoClient.hs @@ -10,6 +10,8 @@ import Control.Monad import Data.ByteString (ByteString) import Data.Maybe (fromMaybe) +import qualified Data.Text.Lazy as TL +import Echo import GHC.Generics (Generic) import Network.GRPC.HighLevel.Client import Network.GRPC.HighLevel.Generated @@ -17,12 +19,10 @@ import Network.GRPC.LowLevel import Options.Generic import Prelude hiding (FilePath) -import Echo - data Args = Args { bind :: Maybe ByteString "grpc endpoint hostname (default \"localhost\")" , port :: Maybe Int "grpc endpoint port (default 50051)" - , payload :: Maybe Text "string to echo (default \"hullo!\")" + , payload :: Maybe TL.Text "string to echo (default \"hullo!\")" } deriving (Generic, Show) instance ParseRecord Args diff --git a/examples/tutorial/Arithmetic.hs b/examples/tutorial/Arithmetic.hs index 9e3f911..2b0a0e6 100644 --- a/examples/tutorial/Arithmetic.hs +++ b/examples/tutorial/Arithmetic.hs @@ -12,7 +12,7 @@ import qualified Proto3.Suite.Types as HsProtobuf import qualified Proto3.Suite.Class as HsProtobuf import qualified Proto3.Wire as HsProtobuf import Control.Applicative ((<*>), (<|>)) -import qualified Data.Text as Hs (Text) +import qualified Data.Text.Lazy as Hs (Text) import qualified Data.ByteString as Hs import qualified Data.String as Hs (fromString) import qualified Data.Vector as Hs (Vector) diff --git a/examples/tutorial/TUTORIAL.md b/examples/tutorial/TUTORIAL.md index d98bf95..9fc8c59 100644 --- a/examples/tutorial/TUTORIAL.md +++ b/examples/tutorial/TUTORIAL.md @@ -29,7 +29,7 @@ This library exposes quite a few modules, but you won't need to worry about most ### Getting started -To start out, we need to generate code for our protocol buffers and RPCs. The `compile-proto-file` command is provided as part of `grpc-haskell`. You can either use `stack install` to install the command globally, or use `stack exec` within the `grpc-haskell` directory. +To start out, we need to generate code for our protocol buffers and RPCs. The `compile-proto-file` command is provided as part of `proto3-suite`. You can either use `stack install` in the `proto3-suite` repository to install the command globally, or use `stack exec` from within the `grpc-haskell` directory. ``` $ stack exec -- compile-proto-file --proto examples/echo/echo.proto > examples/echo/echo-hs/Echo.hs diff --git a/grpc-haskell.cabal b/grpc-haskell.cabal index 66007dc..2374114 100644 --- a/grpc-haskell.cabal +++ b/grpc-haskell.cabal @@ -93,24 +93,6 @@ library CPP-Options: -DDEBUG CC-Options: -DGRPC_HASKELL_DEBUG -std=c99 -executable compile-proto-file - build-depends: base >=4.8 && <5.0 - , async - , bytestring == 0.10.* - , containers ==0.5.* - , grpc-haskell - , optparse-generic - , proto3-suite - , proto3-wire - , system-filepath - , text - , transformers - , turtle - default-language: Haskell2010 - ghc-options: -Wall -g -threaded -rtsopts -with-rtsopts=-N -O2 - hs-source-dirs: tools/compile-proto-file - main-is: Main.hs - executable hellos-server if flag(with-examples) build-depends: diff --git a/nix/proto3-suite.nix b/nix/proto3-suite.nix index 90052d6..f10d891 100644 --- a/nix/proto3-suite.nix +++ b/nix/proto3-suite.nix @@ -1,24 +1,31 @@ { mkDerivation, base, bytestring, cereal, containers, deepseq -, fetchgit, filepath, haskell-src, mtl, parsec, parsers, pipes -, pretty, proto3-wire, QuickCheck, safe, semigroups, stdenv, tasty -, tasty-hunit, tasty-quickcheck, text, transformers, turtle, vector +, fetchgit, filepath, haskell-src, mtl, optparse-generic, parsec +, parsers, pretty, pretty-show, proto3-wire, QuickCheck, safe +, semigroups, stdenv, system-filepath, tasty, tasty-hunit +, tasty-quickcheck, text, transformers, turtle, vector }: mkDerivation { pname = "proto3-suite"; version = "0.1.0.0"; src = fetchgit { - url = "https://github.com/awakenetworks/proto3-suite.git"; - sha256 = "1w5qwwlivrxkd6943rxsw3znk9jjpf7ad11gm0zl4lzq6k3kdinp"; - rev = "46f40d38c4db8a6320bab010ae30e75c83fab6ee"; + url = "https://github.com/awakenetworks/proto3-suite"; + sha256 = "1wqs209sfwjiwvpv8zz49jk9l6pivqz06r0m1rfxvsdmxh80kp7d"; + rev = "48d452d42e8d73acfa88a56a54586d17bae711db"; }; + isLibrary = true; + isExecutable = true; libraryHaskellDepends = [ base bytestring cereal containers deepseq filepath haskell-src mtl - parsec parsers pipes pretty proto3-wire QuickCheck safe semigroups - text transformers vector + parsec parsers pretty pretty-show proto3-wire QuickCheck safe + semigroups text transformers vector + ]; + executableHaskellDepends = [ + base optparse-generic system-filepath turtle ]; testHaskellDepends = [ - base bytestring cereal proto3-wire QuickCheck semigroups tasty - tasty-hunit tasty-quickcheck text transformers turtle + base bytestring cereal pretty-show proto3-wire QuickCheck + semigroups tasty tasty-hunit tasty-quickcheck text transformers + turtle vector ]; description = "A low level library for writing out data in the Protocol Buffers wire format"; license = stdenv.lib.licenses.asl20; diff --git a/nix/proto3-wire.nix b/nix/proto3-wire.nix index 00b43d9..7900204 100644 --- a/nix/proto3-wire.nix +++ b/nix/proto3-wire.nix @@ -1,20 +1,21 @@ { mkDerivation, base, bytestring, cereal, containers, deepseq -, fetchgit, QuickCheck, safe, stdenv, tasty, tasty-hunit -, tasty-quickcheck, text +, doctest, fetchgit, hashable, QuickCheck, safe, stdenv, tasty +, tasty-hunit, tasty-quickcheck, text, unordered-containers }: mkDerivation { pname = "proto3-wire"; version = "1.0.0"; src = fetchgit { - url = "https://github.com/awakenetworks/proto3-wire.git"; - sha256 = "10z1sirmiz29r2nx5dza1y1p3kp83wsq80pz4msxqmaykpyh5iaa"; - rev = "62b50ea460847dde5bc8e63d2f93360d9bfcae9d"; + url = "https://github.com/awakenetworks/proto3-wire"; + sha256 = "1979pccp8c8wvl69r203mji51c8s59mccng6zrw3kf2s1wz5xxqg"; + rev = "8178cc717eb1c438272a7f451862590a8b2d41ff"; }; libraryHaskellDepends = [ - base bytestring cereal containers deepseq QuickCheck safe text + base bytestring cereal containers deepseq hashable QuickCheck safe + text unordered-containers ]; testHaskellDepends = [ - base bytestring cereal QuickCheck tasty tasty-hunit + base bytestring cereal doctest QuickCheck tasty tasty-hunit tasty-quickcheck text ]; description = "A low-level implementation of the Protocol Buffers (version 3) wire format"; diff --git a/release.nix b/release.nix index 1bb8759..4d1993b 100644 --- a/release.nix +++ b/release.nix @@ -257,11 +257,6 @@ let --prefix PATH : ${ghc}/bin ''; - postInstall = pkgs.lib.optionalString pkgs.stdenv.isDarwin '' - wrapProgram $out/bin/compile-proto-file \ - --prefix DYLD_LIBRARY_PATH : ${grpc}/lib - ''; - shellHook = (oldDerivation.shellHook or "") + '' export DYLD_LIBRARY_PATH=${grpc}/lib''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH # This lets us use our custom ghc and python environments in the shell. diff --git a/stack.yaml b/stack.yaml index 05b79ca..d775c64 100644 --- a/stack.yaml +++ b/stack.yaml @@ -9,11 +9,11 @@ packages: - '.' - location: git: git@github.com:awakenetworks/proto3-suite.git - commit: 8db2ceb8c48a3f8dc2cbdc492d1e8cbaf8b62a15 + commit: 10f592cdd5349e33d4924b066d4f6e27ada5e5c5 extra-dep: true - location: git: git@github.com:awakenetworks/proto3-wire.git - commit: 1b88bf24aad15db1f59a00d201d609fa308157f7 + commit: 4cf2f349cbf27ef36af28ae51e2712d6cf5f7723 extra-dep: true # Packages to be pulled from upstream that are not in the resolver (e.g., acme-missiles-0.3) extra-deps: [managed-1.0.5] diff --git a/tools/compile-proto-file/Main.hs b/tools/compile-proto-file/Main.hs deleted file mode 100644 index d973a0c..0000000 --- a/tools/compile-proto-file/Main.hs +++ /dev/null @@ -1,26 +0,0 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE LambdaCase #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE TypeOperators #-} - -import Data.Monoid ((<>)) -import Filesystem.Path.CurrentOS (encodeString) -import Options.Generic -import Proto3.Suite.DotProto.Generate -import Prelude hiding (FilePath) -import Turtle (FilePath) - -data Args = Args - { proto :: FilePath "Path to input .proto file" - } deriving (Generic, Show) -instance ParseRecord Args - -main :: IO () -main = do - protoPath <- encodeString . unHelpful . proto <$> getRecord "Dumps a compiled .proto file to stdout" - readDotProtoWithContext protoPath >>= \case - Left err -> fail (show err) - Right (dp, ctx) -> case renderHsModuleForDotProto dp ctx of - Left err -> fail ("Error compiling " <> protoPath <> ": " <> show err) - Right src -> putStrLn src