I'd like to put together a library where the user can input pieces of a URL (scheme e.g. HTTP, hostname, username, port, path, query, etc.) I'd like to validate the pieces according to the ABNF specified in RFC 3986.
In other words, I'd like to put together a set of functions such as:
validateScheme :: String -> Bool validateUsername :: String -> Bool validatePassword :: String -> Bool validateAuthority :: String -> Bool validatePath :: String -> Bool validateQuery :: String -> Bool
What is the most appropriate tool to use to write these functions?
Alex's regexps is very concise, but it's a tokenizer and doesn't straightforwardly allow you to parse using specific rules, so it's not quite what I'm looking for, but perhaps it can be wrangled into doing this easily.
I've written Parsec code that does some of the above, but it looks very different from the original ABNF and unnecessarily long.
So, there must be an easier and/or more appropriate way. Recommendations?