Hello list,

I've got a collection of types which come from generated code (it's protocol buffer stuff). I'd like to write a polymorphic function which maps the protocol buffer generated data types to native data types. I've tried something like this:

class FromProto a where
    type InputDataType
    fromProto :: InputDataType -> a

instance ToProto SomeNativeType where
    type OutputDataType = SomeGeneratedType
    toProto =
        {- etc -}

instance FromProto SomeOtherNativeType where
    type InputDataType = SomeOtherGeneratedType
    fromProto =
        {- etc -}


Which works fine for mapping one native data type to one generated data type, but breaks when I want to define different InputDataTypes for different instances of FromProto.

I feel like I'm making this more complicated than I need to. Is there an easy way to get the data type to data type mapping that I'm looking for?

Cheers,
Alex