higherkindness / mu-haskell

Mu (μ) is a purely functional framework for building micro services.
http://higherkindness.io/mu-haskell/
Apache License 2.0
333 stars 19 forks source link

Quasi.GRpc fails to parse float in protobuf file #336

Open 4eUeP opened 2 years ago

4eUeP commented 2 years ago

Hi, I'm trying to include this library into grpc_bench. However, it doesn't compile. The reason seems to be a float field in the proto file. (It seems that language-protobuf doesn't support the float field)

Reproduce

-- test.hs
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}

module Main where

import Mu.Quasi.GRpc

grpc "Hello" id "test.proto"

main :: IO ()
main = undefined
// test.proto
syntax = "proto3";

message msg {
  float xx = 1;
}
cabal repl mu-protobuf
> :load test.hs

<no location info>: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules: 
        Mu.Adapter.ProtoBuf Mu.Quasi.GRpc Mu.Quasi.ProtoBuf
[1 of 4] Compiling Mu.Adapter.ProtoBuf ( src/Mu/Adapter/ProtoBuf.hs, interpreted )
[2 of 4] Compiling Mu.Quasi.ProtoBuf ( src/Mu/Quasi/ProtoBuf.hs, interpreted )
[3 of 4] Compiling Mu.Quasi.GRpc    ( src/Mu/Quasi/GRpc.hs, interpreted )
[4 of 4] Compiling Main             ( test.hs, interpreted )

test.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-inplace:Mu.Quasi.ProtoBuf
    Code: grpc "Hello" id "test.proto"
  |
1 | {-# LANGUAGE TemplateHaskell #-}
  | ^
Failed, three modules loaded.
fintara commented 1 year ago

I've hit the same, thanks for submitting this issue 😅

It would be nice (apart from supporting float) to improve the "this should never happen" error and mention that this type is not supported.