Open nwaywood opened 4 years ago
@nwaywood: What version of proto3-suite
are you using to obtain the compile-proto-file
executable? The reason I ask is that I just attempted to update the Arithmetic.hs
example from a recent proto3-suite
revision and did not run into the problem that you described.
The only issue I found was a missing deepseq
dependency which I have a pull request up to fix:
@nwaywood: Hmmm, that's weird because I believe that I'm using that same revision, too. Could you attach the generated Arithmetic.hs
that you got? I'll also double-check the version of compile-proto-file
that I'm using
Here is the Arithmetic
file that is generated by running the command
compile-proto-file --proto arithmetic.proto --out .
from the tutorial
directory (apologies for the file extension being .txt
, I had to rename it from .hs
to .txt
for github to let me upload it).
@Gabriel439 I'm also getting a very similar error, I'm currently using the latest patch on master
proxyServer> • Couldn't match expected type ‘Hs.Maybe
proxyServer> (HsJSONPB.SwaggerType
proxyServer> 'swagger2-2.5:Data.Swagger.Internal.SwaggerKindSchema)’
proxyServer> with actual type ‘HsJSONPB.SwaggerType
proxyServer> 'swagger2-2.5:Data.Swagger.Internal.SwaggerKindSchema’
proxyServer> • In the ‘_paramSchemaType’ field of a record
proxyServer> In the ‘_schemaParamSchema’ field of a record
proxyServer> In the ‘_namedSchemaSchema’ field of a record
proxyServer> |
proxyServer> 17792 | HsJSONPB.SwaggerObject},```
I got the same error, tried to downgrade swagger to 2.3.1.1 and got different error
* Impossible to have an instance HsJSONPB.ToSchema Hs.ByteString.
Please, use a newtype wrapper around Hs.ByteString instead.
Consider using byteSchema or binarySchema templates.
* In the expression: HsJSONPB.declareSchemaRef
In an equation for `declare_dest_custom_records':
declare_dest_custom_records = HsJSONPB.declareSchemaRef
In the expression:
do let declare_dest = HsJSONPB.declareSchemaRef
sendRequestDest <- declare_dest Proxy.Proxy
let declare_dest_string = HsJSONPB.declareSchemaRef
sendRequestDestString <- declare_dest_string Proxy.Proxy
....
|
2417 | let declare_dest_custom_records = HsJSONPB.declareSchemaRef
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@Gabriel439 I see some code in proto3-suite related to this bug (ToSchema instance of ByteString), but seems it's not working in my case. What do you think, how I can workaround it?
I actually know which types are causing these errors, here is example https://github.com/lightningnetwork/lnd/blob/1bd211a7228d2f13ecaf514f611738837c057d94/lnrpc/rpc.proto#L840
Not sure it is right solution or not, but I worked it around with this orphan instance https://github.com/coingaming/lnd-client/blob/d6971ae41da8c8112a65b805ba49106bcad3edf6/src/LndGrpc/Orphans.hs#L11-L12
I just updated to the latest version of the compile-proto-file
binary and can confirm that I now have the same issue as @tim2CF, his solution here solves it for me as well.
This is the only issue I am now having with the latest binary, the original issue is no longer happening :)
Fix is up here: https://github.com/awakesecurity/proto3-suite/pull/140
@Gabriel439 I just tried #140 and I am still getting the error described here
In case some more detail may be useful for you...
This is the snippet of code that I need to add to one of the generated hs
files in my project to make it work.
And as @tim2CF mentioned, I am assuming that the reason why I'm only having issues with that generated file and none of my other ones is because that source proto file contains a map
type
@nwaywood: I think I will need more detailed reproduction instructions, because I'm no longer able to reproduce the problem for the Arithmetic.hs
file on master
@Gabriel439 yes I don't think the issue will happen with the Arithmetic.hs
file anymore since the issue seems to be with the map
type (map documentation) and Arithmetic.proto
contains no map types.
If you don't mind using my project, https://github.com/hyperledger-labs/fabric-chaincode-haskell, then reproduction is very easy.
git clone git@github.com:hyperledger-labs/fabric-chaincode-haskell.git
cd fabric-chaincode-haskell/protos
./generate.sh
cd ..
stack build
The stack build will fail on an error similar to the one @tim2CF described here. In the case of my project, it is failing due to this map
type and I currently fix it manually by adding the code as described in my readme
I just finished doing the Arithmetic tutorial here https://github.com/awakesecurity/gRPC-haskell/blob/master/examples/tutorial/TUTORIAL.md
When I run it using the
Arithmetic.hs
file that was provided in the repo everything works perfectly.However when I try and run it using a freshly generated
Arithmetic.hs
file fromcompile-proto-file
, it fails to compile with the following error:If I manually edit the generated
Arithmetic.hs
file and change lines 161 and 216 fromHsJSONPB.SwaggerObject},
to
Hs.Just HsJSONPB.SwaggerObject},
It works again.