title: Beginner Haskell problems (No instance for ... arising from)
body: <p>I recently started learning Haskell and I'm trying to rewrite something I did for an interview   in python in Haskell.  I'm trying to convert a string from camel case to underscore separated ("myVariableName" -> "my_variable_name"), and also throw an error if the first character is upper case.</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>import qualified Data.Char as Char
  
  translate_java :: String -&gt; String
  translate_java xs = translate_helper $ enumerate xs
      where 
          translate_helper [] = []
          translate_helper ((a, num):xs)
              | num == 1 and Char.isUpper a = error "cannot start with upper"
              | Char.isUpper a              = '_' : Char.toLower a : translate_helper xs
              | otherwise                   = a : translate_helper xs
  
  
  enumerate :: (Num b, Enum b) =&gt; [a] -&gt; [(a,b)]
  enumerate xs = zip xs [1..]
  </code></pre>
  
  <p>I realize It's pretty likely I'm going about this in a weird way, and I'd love advice about better ways to implement this, but I'd like to get this to compile as well.  Here's the error I'm getting now:</p>
  
  <pre><code>Prelude&gt; :r
  [1 of 1] Compiling Main             ( translate.hs, interpreted )
  
  translate.hs:4:20:
      No instance for (Num
                         (([Bool] -&gt; Bool) -&gt; (Char -&gt; Bool) -&gt; Char -&gt; t))
        arising from a use of `translate_helper' at translate.hs:4:20-35
      Possible fix:
        add an instance declaration for
        (Num (([Bool] -&gt; Bool) -&gt; (Char -&gt; Bool) -&gt; Char -&gt; t))
      In the first argument of `($)', namely `translate_helper'
      In the expression: translate_helper $ enumerate xs
      In the definition of `translate_java':
          translate_java xs
                           = translate_helper $ enumerate xs
                           where
                               translate_helper [] = []
                               translate_helper ((a, num) : xs)
                                                  | num == 1 and Char.isUpper a
                                                  = error "cannot start with upper
  "
                                                  | Char.isUpper a
                                                  = '_' : Char.toLower a : transla
  te_helper xs
                                                  | otherwise = a : translate_help
  er xs
  Failed, modules loaded: none.
  </code></pre>
  
  <p>Any explanation of what's going on here would be great.  I really don't understand where "(Num (([Bool] -> Bool) -> (Char -> Bool) -> Char -> t))" is coming from.  I'd think the type declaration for translate_helper would be something like [(a,b)] -> [a]?</p>