title: Overloading Show and Num in typeclass makes execution hang indefinitely
body: <p>I am making assigment on Haskell, and almost solved it.. Feels like I miss some last step, but cant put my finger on, what do I do wrong.</p>
  <p>First my task:</p>
  <blockquote>
  <p>Now, insted of using type synonyms, define data types CountryCode and PhoneNo so that both of them have a value constructor that takes an integer.
  Derive an instance for Eq, Ord and Show for PhoneType.
  Derive instances for Eq and Ord for CountryCode and PhoneNo and make Show instances for them so that:
  CountryCode: print '+' in front of the number.
  PhoneNo: print only the number.
  Make a function for both of them (toCountryCode and toPhoneNo) that takes an Integer and throws an error if the integer is negative otherwise it creates the value.</p>
  </blockquote>
  <blockquote>
  <p>If CountryCode is negative, the error should be &quot;Negative country code&quot; and if PhoneNo is negative, the error should be &quot;Negative phone number&quot; and you should follow these literally to pass the automatic testing.</p>
  </blockquote>
  <blockquote>
  <p>Again, using the record syntax, define Phone type for phone numbers that has only one value constructor with fields</p>
  </blockquote>
  <pre><code>phoneType :: PhoneType,
  countryCode :: CountryCode, (This time the type defined as above)
  phoneNo :: PhoneNo. (This time the type defined as above)
  </code></pre>
  <blockquote>
  <p>Derive an instance for Eq and Ord for the record, but for Show make it &quot;pretty-print&quot; the infromation in this form:
  
  e.g. +358 123456789 (WorkLandline)</p>
  </blockquote>
  <p>Now my take on the task:</p>
  <pre><code>data PhoneType = WorkLandline|PrivateMobile|WorkMobile|Other deriving (Read,Show,Eq)
  
  newtype PlainString = PlainString String
  instance Show PlainString where
    show (PlainString s) = s
  --instance Num Int where
  --   (*)=int_times
  --   (+)=int_plus
  
  data CountryCode = CountryCode
      {
          cCode :: Int
      } deriving (Read,Eq)
  instance Show CountryCode where
      show (CountryCode a)=(show (PlainString &quot;+&quot;)) ++ (show a)
  instance Num CountryCode where 
      (*) a b=a*b 
      (+) a b=a+b 
      (-) a b=a-b
      fromInteger x=fromInteger x 
  
  toCountryCode :: Int-&gt;CountryCode
  toCountryCode ccode  
      | ccode&lt;0=error &quot;Negative country code&quot;
      |otherwise = CountryCode ccode
  
  
  data PhoneNo = PhoneNo
      {
          pNo :: Int
      } deriving (Read,Eq)
  instance Show PhoneNo where
      show (PhoneNo a)=show a
  instance Num PhoneNo where
      (*) a b=a*b
      (+) a b=a+b
      (-) a b=a-b
      fromInteger x= fromInteger x
  
  toPhoneNo :: Int -&gt; PhoneNo
  toPhoneNo pno  
      | pno&lt;0=error &quot;Negative phone number&quot;
      |otherwise = PhoneNo pno
  
  data Phone = Phone
      {
          phoneType :: PhoneType,
          countryCode :: CountryCode,
          phoneNo :: PhoneNo
      } deriving (Read,Eq)
  instance Show Phone where
      show (Phone a b c)=show a
  
  makePhone :: PhoneType -&gt; CountryCode  -&gt; PhoneNo -&gt; Phone
  makePhone phonetype countrycode phoneno
      |otherwise = Phone phonetype countrycode phoneno
  </code></pre>
  <p>This version kinda workds with:
  makePhone Other 1 1
  , which shows <em>Other</em>.</p>
  <p>However, if i modify this to:
  show (Phone a b c)=show b
  or make sane <strong>show</strong> like asked in task - program hangs indefinitely. Same goes for <strong>show c</strong></p>
  <p>What do I do wrong?</p>