title: Making a Read instance in Haskell
body: <p>I have a data type</p>
  
  <pre><code>data Time = Time {hour :: Int,
                    minute :: Int
                   }
  </code></pre>
  
  <p>for which i have defined the instance of Show as being</p>
  
  <pre><code>instance Show Time where
    show (Time hour minute) = (if hour &gt; 10
                               then (show hour)
                               else ("0" ++ show hour))
                              ++ ":" ++
                              (if minute &gt; 10
                               then (show minute)
                               else ("0" ++ show minute))
  </code></pre>
  
  <p>which prints out times in a format of <code>07:09</code>.</p>
  
  <p>Now, there should be symmetry between <code>Show</code> and <code>Read</code>, so after reading (but not truly (i think) understanding) <a href="https://stackoverflow.com/questions/5520940/creating-instance-of-read-type-class-in-haskell-for-custom-data-type">this</a> and <a href="https://stackoverflow.com/questions/7851275/how-to-create-instance-of-read-for-a-datatype-in-haskell">this</a>, and reading the <a href="http://hackage.haskell.org/packages/archive/base/latest/doc/html/Text-Read.html#t%3aRead" rel="noreferrer">documentation</a>, i have come up with the following code:</p>
  
  <pre><code>instance Read Time where
    readsPrec _ input =
      let hourPart = takeWhile (/= ':')
          minutePart = tail . dropWhile (/= ':')
      in (\str -&gt; [(newTime
                    (read (hourPart str) :: Int)
                    (read (minutePart str) :: Int), "")]) input
  </code></pre>
  
  <p>This works, but the <code>""</code> part makes it seem wrong. So my question ends up being:</p>
  
  <p>Can anyone explain to me the correct way to implement Read to parse <code>"07:09"</code> into <code>newTime 7 9</code> and/or show me?</p>