From 42c6cb701a73ff7e51fc997154533fdfb70ebf6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reto=20K=C3=BChni?= Date: Sat, 3 Feb 2024 02:01:39 +0100 Subject: [PATCH] #257 code cleanup --- .vscode/settings.json | 2 +- adapter/protobuf/src/Mu/Quasi/GRpc.hs | 10 +++++----- adapter/protobuf/src/Mu/Quasi/ProtoBuf.hs | 12 ++++++------ stack.yaml | 19 ++++++++++--------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index a14c7ba3..14e3ec3d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { "[haskell]": { "editor.formatOnSave": true, - "editor.defaultFormatter": "haskell.haskell" + "editor.defaultFormatter": "vigoo.stylish-haskell" }, "haskell.formattingProvider": "stylish-haskell" } diff --git a/adapter/protobuf/src/Mu/Quasi/GRpc.hs b/adapter/protobuf/src/Mu/Quasi/GRpc.hs index 2e3a8361..851d8f4d 100644 --- a/adapter/protobuf/src/Mu/Quasi/GRpc.hs +++ b/adapter/protobuf/src/Mu/Quasi/GRpc.hs @@ -31,11 +31,11 @@ import Mu.Rpc grpc :: String -> (String -> String) -> FilePath -> Q [Dec] grpc schemaName servicePrefix fp = do r <- liftIO $ parseProtoBufFile fp - case r of - Left e - -> fail ("could not parse protocol buffers spec: " ++ show e) - Right p - -> grpcToDecls schemaName servicePrefix p =<< loadImports fp p + case r of + Left e + -> fail ("could not parse protocol buffers spec: " ++ show e) + Right p + -> grpcToDecls schemaName servicePrefix p =<< loadImports fp p grpcToDecls :: String -> (String -> String) -> P.ProtoBuf -> [P.ProtoBuf] -> Q [Dec] grpcToDecls schemaName servicePrefix p@P.ProtoBuf { P.package = pkg, P.services = srvs } imps diff --git a/adapter/protobuf/src/Mu/Quasi/ProtoBuf.hs b/adapter/protobuf/src/Mu/Quasi/ProtoBuf.hs index 6742b9af..70e54c9b 100644 --- a/adapter/protobuf/src/Mu/Quasi/ProtoBuf.hs +++ b/adapter/protobuf/src/Mu/Quasi/ProtoBuf.hs @@ -17,22 +17,22 @@ module Mu.Quasi.ProtoBuf ( protobuf -- * Only for internal use , protobufToDecls + , loadImports ) where -import Control.Monad (when, foldM) +import Control.Monad (foldM, when) import Control.Monad.IO.Class import qualified Data.ByteString as B import Data.Int import qualified Data.List as L -import qualified Data.Map.Strict as M -import Data.Maybe (maybe) import Data.List.NonEmpty (NonEmpty (..), toList) +import qualified Data.Map.Strict as M import qualified Data.Text as T import Data.Word import Language.Haskell.TH import Language.ProtocolBuffers.Parser import qualified Language.ProtocolBuffers.Types as P -import System.FilePath (takeDirectory, ()) +import System.FilePath (takeDirectory, ()) import Mu.Adapter.ProtoBuf import Mu.Schema.Annotations @@ -133,8 +133,8 @@ flattenDecls (currentScope :| higherScopes) = concatMap flattenDecl then [qualifyName scopeName ts] else qualifyTOther rest ts where - qualifyName "" ts = T.intercalate "." ts - qualifyName scopeName ts = qualifyName "" (scopeName:ts) + qualifyName "" ts' = T.intercalate "." ts' + qualifyName sn ts'=qualifyName "" (sn:ts') hasDeclFor [] _ = True hasDeclFor [t] (P.DEnum enumName _ _) = t == enumName diff --git a/stack.yaml b/stack.yaml index 18f9a033..a9ae7784 100644 --- a/stack.yaml +++ b/stack.yaml @@ -3,20 +3,20 @@ allow-newer: true packages: - adapter/avro -- adapter/kafka +#- adapter/kafka - adapter/persistent - adapter/protobuf - core/lens - core/optics - core/rpc - core/schema -- examples/health-check -- examples/library/backend -- examples/route-guide -- examples/seed -- examples/todolist -- examples/with-persistent -- graphql +#- examples/health-check +#- examples/library/backend +#- examples/route-guide +#- examples/seed +#- examples/todolist +#- examples/with-persistent +#- graphql - grpc/client - grpc/common - grpc/server @@ -32,9 +32,10 @@ extra-deps: - http2-grpc-proto3-wire-0.1.0.0 - http2-grpc-types-0.5.0.0 - warp-grpc-0.4.0.1 -- hw-kafka-conduit-2.7.0 +#- hw-kafka-conduit-2.7.0 - graphql-1.0.3.0 - stm-hamt-1.2.0.7 - stm-containers-1.2 - tracing-0.0.7.2 - tracing-control-0.0.7.3 +#- unix-2.8.5.0@sha256:633f15ef0bd50a16a7b5c5e86e6659fee6e4e211e098cc8bd0029f452bfcfddc,9808