title: Haskell: "Non type-variable argument in the constraint: Eq Bit" and "No instance for (Eq Bit) arising drom a use of '=='"
body: <pre><code>data Bit = One 
           | Zero
           deriving Show
  
  type Bits = [Bit]
  
  bits2String :: Bits -&gt; String
  bits2String [] = ""
  bits2String (x:xs) | x == One = "1" ++ bits2String xs
                     | x == Zero = "0" ++ bits2String xs
  </code></pre>
  
  <p>This Code causes following error message:</p>
  
  <pre><code>No instance for (Eq Bit) arising drom a use of '=='
  </code></pre>
  
  <p>For this error you can find a lot of  solutions on SO. They always say you need to add Eq like that:</p>
  
  <pre><code>bits2String :: (Eq Bit) =&gt; Bits -&gt; String
  bits2String [] = ""
  bits2String (x:xs) | x == One = "1" ++ bits2String xs
                     | x == Zero = "0" ++ bits2String xs
  </code></pre>
  
  <p>But this doesnt work for me and causes following error</p>
  
  <pre><code>Non type-variable argument in the constraint: Eq Bit
  (Use FlexibleContexts to permit this)
  </code></pre>
  
  <p>{-# LANGUAGE FlexibleContexts #-} doesnt work either.</p>