Haskell: How to pretty print a string without quotes?
<p>Let's assume I have this data type:</p>

<pre><code>data SomeDataType a = SomeDataType a
</code></pre>

<p>I want to show its representation to the user (in the console output), so I need a "pretty print" function. I don't want to use <code>show</code>, because it will return an expression and I just want the value of my type's only field converted to a string. </p>

<p>I expect this behaviour:</p>

<pre><code>&gt;&gt;&gt; let myintdata = SomeDataType (22::Int)
&gt;&gt;&gt; putStrLn $ prettyPrint myintdata
22
&gt;&gt;&gt; let alice = SomeDataType "Alice"
&gt;&gt;&gt; let bob = SomeDataType "Bob"
&gt;&gt;&gt; putStrLn $ prettyPrint alice ++ " loves " ++ prettyPrint bob
Alice loves Bob
</code></pre>

<p>So I implement it like this:</p>

<pre><code>prettyPrint :: Show a =&gt; SomeDataType a -&gt; String
prettyPrint (SomeDataType x) = show x
</code></pre>

<p>It's working fine for numbers, but strings are getting quoted and escaped:</p>

<pre><code>&gt;&gt;&gt; let alice = SomeDataType "Alice"
&gt;&gt;&gt; let bob = SomeDataType "Bob"
&gt;&gt;&gt; putStrLn $ prettyPrint alice ++ " loves " ++ prettyPrint bob
"Alice" loves "Bob"
</code></pre>

<p>Also, I want full control on how different content types are converted to strings in the future. So, I'm off to create my own typeclass! It goes like this:</p>

<pre><code>{-# LANGUAGE FlexibleInstances #-}

data SomeDataType a = SomeDataType a

class PrettyPrint a where
    prettyPrint :: a -&gt; String

instance {-# OVERLAPPABLE #-} PrettyPrint a where
    -- I don't care about this right now,
    -- let's learn how to print strings without quotes first!
    prettyPrint = const "Stupid Robot" 

instance PrettyPrint String where
    prettyPrint = id

instance Show a =&gt; PrettyPrint (SomeDataType a) where
    prettyPrint (SomeDataType x) = prettyPrint x
</code></pre>

<p>I'm happy with the first test:</p>

<pre><code>&gt;&gt;&gt; putStrLn $ prettyPrint "No quotes!"
No quotes!
</code></pre>

<p>But when I'm trying to pretty print my data type, somehow general instance is being invoked instead of String's:</p>

<pre><code>&gt;&gt;&gt; let alice = SomeDataType "Alice"
&gt;&gt;&gt; let bob = SomeDataType "Bob"
&gt;&gt;&gt; putStrLn $ prettyPrint alice ++ " loves " ++ prettyPrint bob
Stupid Robot loves Stupid Robot
</code></pre>

<p>At this point I suspect there is a completely different way to approach this "pretty printing" problem. Is that so? Or am I missing some simple obvious mistake in my code?</p>