Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haskell/network-uri
URI manipulation facilities
https://github.com/haskell/network-uri
Last synced: about 1 month ago
JSON representation
URI manipulation facilities
- Host: GitHub
- URL: https://github.com/haskell/network-uri
- Owner: haskell
- License: other
- Created: 2014-08-16T16:04:14.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-02-16T10:53:06.000Z (9 months ago)
- Last Synced: 2024-04-16T00:49:07.087Z (7 months ago)
- Language: Haskell
- Size: 170 KB
- Stars: 24
- Watchers: 10
- Forks: 33
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
The network-uri package
=======================This package provides facilities for parsing and unparsing URIs, and creating
and resolving relative URI references, closely following the URI spec, IETF
RFC 3986 [1].The main module in this package, `Network.URI`, was split off from the
network package in the network-2.6 release.# Network.URI.Static
Network.URI.Static that allows you to declare static URIs in type-safe manner.
With the base module, when you declare a static URI, you need to either use `Maybe URI` or use `URI` and give up type safety.
```haskell
safeButWrappedInMaybeURI :: Maybe URI
safeButWrappedInMaybeURI = parseURI "http://www.google.com/"directButUnsafeURI :: URI
directButUnsafeURI = fromJust $ parseURI "http://www.google.com/"
```This library allows you to write static URIs in type-safe manner by checking URIs at compile time using template haskell.
Now, you can write the following.
```haskell
directAndSafeURI :: URI
directAndSafeURI = $$(staticURI "http://www.google.com")
```You can even use a quasi quote if you'd like.
```haskell
directAndSafeURI :: URI
directAndSafeURI = [uri|"http://www.google.com"|]
```These two expressions emit an error at compile time if a specified URI is malformed.