title: Understanding Read instance
body: <p>I made <code>Read</code> and <code>Show</code> instances of my data, but did not understand the <code>Read</code> instance</p>
  
  <pre><code>data Tests = Zero
            | One Int
            | Two Int Double
  
  instance Show Tests where
    show Zero      = "ZERO"
    show (One i)   = printf "ONE %i" i
    show (Two i j) = printf "TWO %i %f" i j
  
  instance Read Tests where
    readsPrec _ str   = [(mkTests str, "")]
  
  mkTests :: String -&gt; Tests
  mkTests = check . words
  
  check :: [String] -&gt; Tests
  check ["ZERO"]      = Zero
  check ["ONE", i]    = One (read i)
  check ["TWO", i, j] = Two (read i) (read j)
  check _             = error "no parse"
  
  main :: IO ()
  main = do
    print Zero
    print $ One 10
    print $ Two 1 3.14
  
    let x = read "ZERO" :: Tests
    print x
    let y = read "ONE 2" :: Tests
    print y
    let z = read "TWO 2 5.5" :: Tests
    print z
  </code></pre>
  
  <p>This is output </p>
  
  <pre><code>ZERO         
  ONE 10       
  TWO 1 3.14   
  ZERO         
  ONE 2        
  TWO 2 5.5  
  </code></pre>
  
  <p><strong>Here are questions:</strong></p>
  
  <ol>
  <li><p>What is recommend way to implement <code>Read</code> instance?</p>
  
  <ul>
  <li>The minimal complete definition of <code>Read</code> class is <code>readsPrec | readPrec</code>
  and <code>readPrec :: ReadPrec a</code> description wrote</li>
  </ul>
  
  <blockquote>
    <p>Proposed replacement for readsPrec using new-style parsers (GHC only).</p>
  </blockquote>
  
  <ul>
  <li>Should I use <code>readPrec</code> instead, How? I can't find any example on the net that I can understand.</li>
  <li>What is the <code>new-style parsers</code>, is it <code>parsec</code>?</li>
  </ul></li>
  <li><p>What is the first <code>Int</code> argument of <a href="https://hackage.haskell.org/package/base/docs/Text-Read.html#v:readsPrec" rel="nofollow noreferrer">readsPrec :: Int -> ReadS a </a>, is using for?</p></li>
  <li><p>Is there anyway to somehow deriving <code>Read</code> from <code>Show</code>?</p></li>
  </ol>
  
  <p>In the past I could use <code>deriving (Show,Read)</code> to most of the job. But this time I want to move to next level.</p>