title: How to check for each char of a string in Haskell
body: <p>I've got a homework for a function that checks if a username is valid or not. Allowed chars are underscore, letters, and digits. I'm not allowed to use indexing (!!) and Length</p>
  
  <p>My code so far:</p>
  
  <pre><code>isValid' :: Char -&gt; Bool
  isValid' x
       | x == '_'    = True
       | x `elem` ['0'..'9'] = True
       | x `elem` ['a'..'z'] = True
       | x `elem` ['A'..'Z'] = True
       | otherwise           = False
  
  isValidUsername :: [Char] -&gt; Bool
  isValidUsername x
       | map isValid' x = True
       | otherwise     = False
  </code></pre>
  
  <p>I want to run my isValid function on all chars of the string i put in isValidUsername. For example:</p>
  
  <p><code>isValidUsername "MyUsername_123"</code> should return True</p>
  
  <p><code>isValidUsername "not@v@lidusern@me* *2"</code> should return False</p>
  
  <p>I just can't figure out how to run through all the chars of my string.</p>