
Ah, thank you! Now it works.
Now I need only to get rid of the Right from the returned Either value
and I'm done.
Raphael
On 5/12/11, Daniel Fischer
On Thursday 12 May 2011 18:21:45, Raphael Päbst wrote:
Hey! I am currently working on a project, where I need to serialize data with ProtocolBuffers. I have managed to compile a .proto file and serialize messages with messagePut. However, when I try to deserialize a ByteString again, I get the following error:
ambiguous type variable `msg0' in the constraints: (Text.ProtocolBuffers.WireMessage.Wire msg0) arising from a use of "messageGet" at... (Text.ProtocolBuffers.Reflections.ReflectDescriptor msg0) arising from a use of "messageGet" at ... Probable fix: add a type signature that fixes these type variables in the expression "messageGet bs" in an equation for `IT': "IT = messageGet bs"
I'm trying to call messageGet from the prompt in ghc. What exactly am I doing wrong? And how can I fix this?
You have to tell it which type you want, so it can choose the correct messageGet.
If you type
ghci> read "True"
it doesn't know either and you have to tell it (and of course the result would be different for result type Bool than for Integer).
So you have to type
ghci> messageGet bs :: WhateverWireYouWant
to disambiguate the type.
In programmes, there's rarely a need to provide such expression type signatures because the type can usually be inferred from the context. If there's not enough context to infer the type - especially if there's no context - you have to provide an explicit type.
Many Thanks
Raphael