I define a Wrapper type just for carrying the type information. In the showToString, my hope is that since I specify the exact type of Wrapper, then the typechecker can infer that the a in function'' is and Int and pick the Int instance of the ToString typeclass.

But the reality doesn't correspond with my hopes, this is the message from compiler

Could not deduce (ToString a0) arising from a use of `toString'

Is there a way, how to convince the compiler, that he can pick the right typeclass in the function'', because I specify the it by having the type declaration of :: Wrapper Int?

The idea is that I want an a to pass to toString but only Wrapper a shows up in my type. So I just define a function which takes Wrapper a and produces a – such a function can't have a real implementation, but we're not using it for its return value anyway – and apply it to the Wrapper a thing.

There's a bit of additional awkwardness because Wrapper a shows up in the result instead of an argument, but this (slightly silly) recursion takes care of that.