Dormouse-Uri provides type safe handling of Uris and Urls.

Uri sytax is well defined according to RFC 3986, Dormouse-Uri parses and encodes Uris according to the syntax defined in this document.

We define Url as an absolute URI associated with web resources, the current version of Dormouse-Uri restricts Urls to the http and https schemes.

Dormouse-Uri has the following features:


Dormouse-Uri on Hackage Dormouse-Uri on Hackage

Future Development

Constructing Uris

{-# LANGUAGE QuasiQuotes #-}

import Dormouse.Uri
import Dormouse.Uri.QQ

telUri :: Uri
telUri = [uri|tel:+1-816-555-1212|]

mailtoUri :: Uri
mailtoUri = [uri||]

httpUri :: Uri
httpUri = [uri||]

Constructing Urls

You can construct Urls using the helper QuasiQuoters:

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE QuasiQuotes #-}

import Dormouse.Url
import Dormouse.Url.QQ

githubHttpsUrl :: Url "https"
githubHttpsUrl = [https||]

githubHttpUrl :: Url "http"
githubHttpUrl = [http||]

githubAnyUrl :: AnyUrl
githubAnyUrl = [url||]

Safe Url Construction

You can use the Url Builder syntax to modify an existing Url safely to include paths, adding the import:

import Dormouse.Url.Builder

To allow:

dormouseHttpsUrl :: Url "https"
dormouseHttpsUrl = githubHttpsUrl </> "TheInnerLight" </> "dormouse"

The Url will be constructed safely so that any characters that wouldn't normally be allowed in a Url path are percent-encoded before the url is resolved by Dormouse.

You can also handle query parameters using similar syntax:

searchUrl :: Url "https"
searchUrl = [https||] </> "search" ? "q" =: ("haskell" :: String)