BSD-3-Clause licensed and maintained by Mark Karpov
This version can be pinned in stack with:modern-uri-0.1.0.0@sha256:a76d3507b4538c6880cf6e03bef90e680e5495b19668c18c95cf02a4b1860da3,3938

Module documentation for 0.1.0.0

Modern URI

License BSD3 Hackage Stackage Nightly Stackage LTS Build Status Coverage Status

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

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

Features

The modern-uri package features:

  • Correct by construction URI data type. Correctness is ensured by guaranteeing that every sub-component of the URI record is by itself cannot be invalid. This boils down to careful use of types and a set of smart constructors for things like scheme, host, etc.
  • Textual components in the URI data type represented as Text rather than ByteString, because they are percent-decoded and so they can contain characters outside of ASCII range (i.e. Unicode). This allows for easier manipulation of URIs, while encoding and decoding headaches are handled by the parsers and renders for you.
  • Absolute and relative URIs differ only by the scheme component: if it’s Nothing, then URI is relative, otherwise it’s absolute.
  • Megaparsec parser that can be used as a standalone smart constructor for the URI data type (see mkURI) as well as be seamlessly integrated into a bigger Megaparsec parser that consumes strict Text (see parser) or strict ByteString (see parserBs).
  • The parser performs some normalization, for example it collapses consecutive slashes. Some smart constructors such as mkScheme and mkHost also perform normalization. So in a sense URIs are also “normalized by construction” to some extent.
  • Fast rendering to strict Text and ByteString as well as to their respective Builder types and to String/ShowS.
  • Extensive set of lensy helpers for easier manipulation of the nested data types (see Text.URI.Lens).
  • Quasi-quoters for compile-time construction of the URI data type and refined text types (see Text.URI.QQ).

Contribution

Issues, bugs, and questions may be reported in the GitHub issue tracker for this project.

Pull requests are also welcome and will be reviewed quickly.

License

Copyright © 2017 Mark Karpov

Distributed under BSD 3 clause license.

Changes

Modern URI 0.1.0.0

  • Changed the type of uriAuthority from Maybe Authority to Either Bool Authority. This allows to know if URI path is absolute or not without duplication of information, i.e. when the Authority component is present the path is necessarily absolute, otherwise the Bool value tells if it’s absolute (True) or relative (False).

  • Added isPathAbsolute in Text.URI and the corresponding getter in Text.URI.Lens.

Modern URI 0.0.2.0

  • Added the renderStr and renderStr' functions for efficient rendering to String and ShowS.

  • Added the parserBs that can consume strict ByteString streams.

Modern URI 0.0.1.0

  • Initial release.