title: Removing String double-quotes in Haskell
body: <p>This function generates simple .dot files for visualizing automata transition functions using Graphviz. It's primary purpose is debugging large sets of automatically generated transitions (e.g., the inflections of Latin verbs).</p>
  
  <pre><code>prepGraph :: ( ... ) =&gt; NFA c b a -&gt; [String]
  prepGraph nfa = "digraph finite_state_machine {"
                : wrapSp "rankdir = LR"
                : wrapSp ("node [shape = circle]" ++ (mapSp (states nfa \\ terminal nfa)))
                : wrapSp ("node [shape = doublecircle]" ++ (mapSp $ terminal nfa))
                : formatGraph nfa ++ ["}"]
  
  formatGraph :: ( ... ) =&gt; NFA c b a -&gt; [String]
  formatGraph = map formatDelta . deltaTuples
   where formatDelta (a, a', bc) = wrapSp (mkArrow a a' ++ " " ++ mkLabel bc)
         mkArrow x y   = show x ++ " -&gt; " ++ show y
         mkLabel (y, z) = case z of
           (Just t) -&gt; "[ label = \"(" ++ show y ++ ", " ++ show t ++ ")\" ]"
           Nothing  -&gt; "[ label = \"(" ++ show y ++ ", " ++ "Null" ++ ")\" ]"
  </code></pre>
  
  <p>where <code>wrap</code>, <code>wrapSp</code> and <code>mapSp</code> are formatting functions, as is <code>deltaTuples</code>.</p>
  
  <p>The problem is that <code>formatGraph</code> retains double quotes around Strings, which causes errors in Graphviz. E.g., when I print <code>unlines $ prepGraph</code> to a file, I get things like:</p>
  
  <pre><code>0 -&gt; 1 [ label = "('a', "N. SF")" ];
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>0 -&gt; 1 [ label = "('a', N. SF)" ];
  </code></pre>
  
  <p>(However, "Null" seems to work fine, and outputs perfectly well). Now of course the string "N. SF" isn't the actual form I use to store inflections, but that form does include a String or two. So how can I tell Haskell: when you <code>show</code> a String values, don't double-quote it?</p>