Network.URI

| Haskell Core Libraries (network package) | Contents | Index
Network.URI |
Portability | non-portable (needs Text.Regex)
Stability | provisional
Maintainer | libraries@haskell.org
Contents
The `URI` type Parsing a `URI` Computing relative `URI`s Operations on `URI` strings
Description
This library provides utilities for parsing and manipulating Uniform Resource Identifiers (a more general form of Uniform Resource Locators, or URLs). URIs are described in RFC 2396 http://www.ietf.org/rfc/rfc2396.txt.
Synopsis
data URI = URI {
scheme :: String
authority :: String
path :: String
query :: String
fragment :: String
}
parseURI :: String -> Maybe URI
relativeTo :: URI -> URI -> Maybe URI
reserved :: Char -> Bool
unreserved :: Char -> Bool
isAllowedInURI :: Char -> Bool
escapeString :: String -> (Char -> Bool) -> String
unEscapeString :: String -> String
The `URI` type
data URI
The decomposition of a general universal resource identifier. For example, for the URI
       http://www.haskell.org/ghc?query#frag
the components are ...
Constructors
URI |
scheme :: String |
    http
authority :: String |
    www.haskell.org
path :: String |
    /ghc
query :: String |
    query
fragment :: String |
    frag
Instances
Show URI
Parsing a `URI`
parseURI :: String -> Maybe URI
Turns a string into a `URI`. It returns `Nothing` if the string isn't a valid URI.
Computing relative `URI`s
relativeTo :: URI -> URI -> Maybe URI
Returns a new `URI` which represents the value of the first `URI` relative to the second `URI`. For example
      "foo" `relativeTo` "http://bar.org/" = "http://bar.org/foo"
Operations on `URI` strings
support for putting strings into URI-friendly escaped format and getting them back again. This can't be done transparently, because certain characters have different meanings in different kinds of URI.
reserved :: Char -> Bool
Returns `True` if the character is a "reserved" character in a URI. To include a literal instance of one of these characters in a component of a URI, it must be escaped.
unreserved :: Char -> Bool
Returns `True` if the character is an "unreserved" character in a URI. These characters do not need to be escaped in a URI. The only characters allowed in a URI are either `reserved`, `unreserved`, or an escape sequence (`%` followed by two hex digits).
isAllowedInURI :: Char -> Bool
Returns `True` if the character is allowed in a URI.
escapeString
:: String | the string to process
-> (Char -> Bool) | a predicate which returns `False` if the character should be escaped
-> String |
Can be used to make a string valid for use in a URI.
unEscapeString :: String -> String
Turns all instances of escaped characters in the string back into literal characters.
Produced by Haddock version 0.6