Errors when interpolating polymorphic "Show" value
With the current implementation of Interpolatable, the following code fails:
display :: Show a => a -> String
display x = [i|This is a value: #{x}|]
with the following error:
• Overlapping instances for string-interpolate-0.1.0.1:Data.String.Interpolate.Conversion.Interpolatable
'True a Text.Text
arising from a use of ‘string-interpolate-0.1.0.1:Data.String.Interpolate.Conversion.interpolate’
Matching instances:
instance [overlappable] Show src =>
string-interpolate-0.1.0.1:Data.String.Interpolate.Conversion.Interpolatable
'True src Text.Text
-- Defined in ‘string-interpolate-0.1.0.1:Data.String.Interpolate.Conversion’
instance [overlap ok] string-interpolate-0.1.0.1:Data.String.Interpolate.Conversion.Interpolatable
'True Text.Text Text.Text
-- Defined in ‘string-interpolate-0.1.0.1:Data.String.Interpolate.Conversion’
instance [overlap ok] string-interpolate-0.1.0.1:Data.String.Interpolate.Conversion.Interpolatable
'True Char Text.Text
-- Defined in ‘string-interpolate-0.1.0.1:Data.String.Interpolate.Conversion’
...plus one other
...plus five instances involving out-of-scope types
(use -fprint-potential-instances to see them all)
(The choice depends on the instantiation of ‘a’
To pick the first instance above, use IncoherentInstances
when compiling the other instance declarations)
I can get around this with
display :: Show a => a -> String
display x = [i|This is a value: #{show x}|]
but it would be nice if this wasn't necessary. I understand if this isn't possible with the way the package is designed, so feel free to close this, but it might be at least worth a mention in the README (it mentions that the quasiquoter can't return an arbitrary IsString, but it doesn't say anything about the input values needing to be concrete types)