alphaHeavy / protobuf

An implementation of Google's Protocol Buffers in Haskell.
http://hackage.haskell.org/package/protobuf
BSD 3-Clause "New" or "Revised" License
96 stars 18 forks source link

Encoding Repa Array #15

Open ftomassetti opened 9 years ago

ftomassetti commented 9 years ago

Hi, I have this type:

type HeightMap a  = Array U DIM2 a

and I would like to use it in a field. Now, doing:

instance Encode (Array U DIM2 Float)

Does not work as I expected, it gives me:

   No instance for (protobuf-0.1.3:Data.ProtocolBuffers.Encode.GEncode
                       (G.Rep (Array U DIM2 Float)))
      arising from a use of `protobuf-0.1.3:Data.ProtocolBuffers.Encode.$gdmencode'
    Possible fix:
      add an instance declaration for
      (protobuf-0.1.3:Data.ProtocolBuffers.Encode.GEncode
         (G.Rep (Array U DIM2 Float)))
    In the expression:
      (protobuf-0.1.3:Data.ProtocolBuffers.Encode.$gdmencode)
    In an equation for `encode':
        encode = (protobuf-0.1.3:Data.ProtocolBuffers.Encode.$gdmencode)
    In the instance declaration for `Encode (Array U DIM2 Float)'

So I thought I should delcare:

instance Encode (G.Rep (Array U DIM2 Float))

But it complains:

Expecting one more argument to `G.Rep (Array U DIM2 Float)'

Any idea about what I am supposed to do? Thanks a million!

NathanHowell commented 9 years ago

Do you need decode support or is encode sufficient?

ftomassetti commented 9 years ago

mmm no I would need also decode support

NathanHowell commented 9 years ago

I might be able to make something generic for decode using Unfoldable.. Can you use a PackedList for now and convert it to a Repa array as needed?

ftomassetti commented 9 years ago

well, for now I have just writing the proto file manually and using protoc to generate haskell bindings, I would prefere to remove the proto file and use protobuf when it supports Repa arrays