title: Why would this code produce a segfault?
body: <p>I am trying to write a module that parses xml from an api, strips out some information, and prints the result as json, but I've hit a hiccup at the printing step. If I print shows I do indeed see that the correct data is there, however, the call which should transform the records into json, <code>encode shows</code>, produces a segfault.</p>
  
  <pre><code>{-# LANGUAGE Arrows, NoMonomorphismRestriction, OverloadedStrings #-}
  import Network.HTTP
  import Text.XML.HXT.Core
  import Data.Aeson
  import qualified Data.ByteString.Lazy.Char8 as LazyByteString
  
  openUrl :: String -&gt; IO String
  openUrl url = getResponseBody =&lt;&lt; simpleHTTP (getRequest url)
  
  composeSearch :: String -&gt; String
  composeSearch query = "http://services.tvrage.com/feeds/search.php?show=" ++ urlEncode query
  
  searchShow :: String -&gt; IO String
  searchShow query = openUrl $ composeSearch query
  
  data TvShow = TvShow { showName, showId :: String } deriving (Show)
  
  getShow = deep (isElem &gt;&gt;&gt; hasName "show") &gt;&gt;&gt;
      proc x -&gt; do
          name &lt;- getText &lt;&lt;&lt; getChildren &lt;&lt;&lt; deep (hasName "name")  -&lt; x
          id &lt;- getText &lt;&lt;&lt; getChildren &lt;&lt;&lt; deep (hasName "showid") -&lt; x 
          returnA -&lt; TvShow { showName = name, showId = id }
  
  instance ToJSON TvShow where
      toJSON (TvShow name id) = object ["name" .= name, "id" .= id]
  
  main :: IO ()
  main = do
      results &lt;- searchShow "Always Sunny" 
      shows &lt;- runX (readString [ withValidate  no ] results &gt;&gt;&gt; getShow)
      putStrLn (LazyByteString.unpack (encode shows))
  </code></pre>
  
  <p><strong>Edit:</strong> As user1891025 has pointed out, This may be an issue with my machine or package versions. </p>
  
  <ul>
  <li>System: Ubuntu 11.04 32bit</li>
  <li>Aeson v0.6.1.0</li>
  <li>GHC v7.2.1</li>
  </ul>
  
  <p>This question is getting increasing specific, so I will take it to irc, but if anyone has any assistance please let me know!</p>