HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulemodern-uri-0.3.6.0Haskell2010

Text.URI

This is a modern library for working with URIs as per RFC 3986:

https://tools.ietf.org/html/rfc3986

This module is intended to be imported qualified, e.g.:

import Text.URI (URI)
import qualified Text.URI as URI

See also Text.URI.Lens for lens, prisms, and traversals; see Text.URI.QQ for quasi-quoters for compile-time validation of URIs and refined text components.

  • 9 types
  • 23 values

Data types

12 declarations
datadata URI
#

Uniform resource identifier (URI) reference. We use refined Text (RText l) here because information is presented in human-readable form, i.e. percent-decoded, and thus it may contain Unicode characters.

Constructors

Instances10Eq, Data, Ord, Show, Generic, NFData, …
valuemkURI :: MonadThrow m => Text -> m URI
#

Construct a URI from Text. The input you pass to mkURI must be a valid URI as per RFC 3986, that is, its components should be percent-encoded where necessary. In case of parse failure ParseException is thrown.

This function uses the parser parser under the hood, which you can also use directly in a Megaparsec parser.

valuemkURIBs :: MonadThrow m => ByteString -> m URI
#

Construct a URI from ByteString. The input you pass to mkURIBs must be a valid URI as per RFC 3986, that is, its components should be percent-encoded where necessary. In case of parse failure ParseExceptionBs is thrown.

This function uses the parserBs parser under the hood, which you can also use directly in a Megaparsec parser.

datadata Authority
#

Authority component of URI.

Constructors

Instances10Eq, Data, Ord, Show, Generic, NFData, …
datadata UserInfo
#

User info as a combination of username and password.

Constructors

Instances10Eq, Data, Ord, Show, Generic, NFData, …
datadata QueryParam
#

Query parameter either in the form of flag or as a pair of key and value. A key cannot be empty, while a value can.

Constructors

Instances10Eq, Data, Ord, Show, Generic, NFData, …
newtypenewtype ParseException
#

Parse exception thrown by mkURI when a given Text value cannot be parsed as a URI.

Constructors

Instances7Eq, Data, Show, Generic, Exception, NFData, …
newtypenewtype ParseExceptionBs
#

Parse exception thrown by mkURIBs when a given ByteString value cannot be parsed as a URI.

Constructors

Instances7Eq, Data, Show, Generic, Exception, NFData, …

Refined text

12 declarations

Refined text values can only be created by using the smart constructors listed below, such as mkScheme. This eliminates the possibility of having an invalid component in URI which could invalidate the whole URI.

Note that the refined text RText type is labelled at the type level with RTextLabels, which see.

When an invalid Text value is passed to a smart constructor, it rejects it by throwing the RTextException. Remember that the Maybe datatype is also an instance of MonadThrow, and so one could as well use the smart constructors in the Maybe monad.

newtypenewtype RText (l :: RTextLabel)
#

Refined text labelled at the type level.

Instances17Lift, Eq, Data, Ord, Show, Generic, …
datadata RTextLabel
#
Instances6Eq, Data, Ord, Show, Generic, Rep
datadata RTextException
#

The exception is thrown when a refined RText l value cannot be constructed due to the fact that given Text value is not correct.

Constructors

Instances7Eq, Data, Ord, Show, Generic, Exception, …

Parsing

2 declarations

The input you feed into the parsers must be a valid URI as per RFC 3986, that is, its components should be percent-encoded where necessary.

valueparser :: MonadParsec e Text m => m URI
#

This parser can be used to parse URI from strict Text. Remember to use a concrete non-polymorphic parser type for efficiency.

Rendering

6 declarations

Rendering functions take care of constructing correct URI representation as per RFC 3986, that is, percent-encoding will be applied when necessary automatically.