Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imports in protobuf #257

Open
akshaymankar opened this issue Nov 13, 2020 · 7 comments
Open

Imports in protobuf #257

akshaymankar opened this issue Nov 13, 2020 · 7 comments
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed protobuf
Milestone

Comments

@akshaymankar
Copy link
Contributor

It seems they are not supported. The template haskell code just ignores them (except for google.protobuf.Empty).

@kutyel kutyel added enhancement New feature or request protobuf help wanted Extra attention is needed labels Nov 13, 2020
@serras
Copy link
Collaborator

serras commented Nov 17, 2020

You are right, our first iteration just ignored them. The reason is that it's not easy to track where in the filesystem or in the web you can find each import. If you have references, I am happy to give it a go in the next weeks (we also accept PRs, of course!).

@serras serras mentioned this issue Nov 17, 2020
@akshaymankar
Copy link
Contributor Author

I think it is sufficient to only look for the files in filesystem. There is no standard place to look, the protoc binary accepts a --proto-path argument which specifies where the imports will be looked for.

For reference, the language guide does a decent job of explaining this.

I don't know if I will get any time to make a PR for this, I am just hacking around on the weekends for now, so I wouldn't make any promises 😄

@rossabaker
Copy link

I am getting this error on a gRPC definition with imports. Calls without imports work. Is it correct to think this error is a manifestation of the import limitation?

src/Schema.hs:1:1: error:
    Exception when trying to run compile-time code:
      this should never happen
CallStack (from HasCallStack):
  error, called at src/Mu/Quasi/ProtoBuf.hs:72:27 in mu-protobuf-0.4.2.0-JgUiVj2yesRLbegUU1AGsL:Mu.Quasi.ProtoBuf
    Code: grpc
            "PubSubSchema" id "googleapis/google/pubsub/v1/pubsub.proto"
  |
1 | {-# LANGUAGE DataKinds #-}
  | ^

@kutyel kutyel added the bug Something isn't working label Apr 15, 2021
@kutyel
Copy link
Member

kutyel commented Apr 16, 2021

Hey! @rossabaker seems related, we are currently discussing how to solve this and will likely come up with a fix soon, thanks!! 🙌🏻

@kutyel kutyel added this to the 0.5.1 milestone Apr 16, 2021
@rossabaker
Copy link

Thanks, @kutyel! I ran into this on the googleapis, if you're looking for a good real-world example. We're enjoying the library very much, and I'll be more than happy to test.

@ProofOfKeags
Copy link

Just ran into something like this as well. One of the methods by which this is handled in the proto-lens library is through using extra-src-files in the package.yaml/cabal file. Perhaps the TH could get at that info and just iterate through the .proto files?

@david9991
Copy link

Does this error related to this issue?


/usr/src/app/src/Ladder.hs:30:46: error:
    • Expected kind ‘Mu.Rpc.Package
                       ghc-prim-0.6.1:GHC.Types.Symbol
                       ghc-prim-0.6.1:GHC.Types.Symbol
                       ghc-prim-0.6.1:GHC.Types.Symbol
                       (Mu.Rpc.TypeRef ghc-prim-0.6.1:GHC.Types.Symbol)’,
        but ‘Service’ has kind ‘Mu.Rpc.Package
                                  ghc-prim-0.6.1:GHC.Types.Symbol
                                  ghc-prim-0.6.1:GHC.Types.Symbol
                                  ghc-prim-0.6.1:GHC.Types.Symbol
                                  (Mu.Rpc.TypeRef *)’
    • In the second argument of ‘SingleServerT’, namely ‘Service’
      In the type ‘SingleServerT i Service m _’
      In the type signature:
        server :: (MonadServer m) => SingleServerT i Service m _
   |        
30 | server :: (MonadServer m) => SingleServerT i Service m _

I have to work around this by expending TemplateHaskell splice to:


type MySchema =
  '[ 'DRecord "HelloRequest" '[ 'FieldDef "name" ('TPrimitive Text)],
     'DRecord "HelloReply" '[ 'FieldDef "message" ('TPrimitive Text)]
   ]

type instance
  AnnotatedSchema ProtoBufAnnotation MySchema =
    '[ 'AnnField "HelloRequest" "name" ('ProtoBufId 1 '[]),
       'AnnField "HelloReply" "message" ('ProtoBufId 1 '[])
     ]

type Service =
  'Package ('Just "myservice") '[ 'Service "Service" '[ 'Method "SayHello" '[ 'ArgSingle ('Nothing :: Maybe Symbol) ('SchemaRef MySchema "HelloRequest")] ('RetSingle ('SchemaRef MySchema "HelloReply"))]]

And then add a :: Package' at the end of the type definition of the Service.

woodworm83 pushed a commit to woodworm83/mu-haskell that referenced this issue Feb 3, 2024
woodworm83 pushed a commit to woodworm83/mu-haskell that referenced this issue Feb 3, 2024
woodworm83 pushed a commit to woodworm83/mu-haskell that referenced this issue Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed protobuf
Projects
None yet
Development

No branches or pull requests

6 participants