Copyright | (c) Athan L. Clark |
---|---|
License | MIT |
Maintainer | Athan L. Clark <athan.clark@gmail.com> |
Stability | experimental |
Portability | GHC |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This library helps us distinguish how we present URLs - we might show them
relatively, absolutely (with the URI authority - scheme, port, hostname, etc.),
or grounded - where the path begins with /
.
We leverage Chris Done's path library to distinguish relative vs. grounded paths at compile time, and provide some additional features like a file extension and query parameters in path-extra.
Synopsis
- class MonadUrl base (m :: * -> *) | m -> base where
- data URL
- printURL :: URL -> Text
- newtype RelativeUrlT m a = RelativeUrlT {
- runRelativeUrlT :: m a
- type RelativeUrl = RelativeUrlT Identity
- newtype GroundedUrlT m a = GroundedUrlT {
- runGroundedUrlT :: m a
- type GroundedUrl = GroundedUrlT Identity
- newtype AbsoluteUrlT m a = AbsoluteUrlT {
- runAbsoluteUrlT :: (Location Abs -> URI) -> m a
- type AbsoluteUrl = AbsoluteUrlT Identity
- mkUriLocEmpty :: Location Abs -> URI
- getPathChunks :: Path base type' -> Vector Text
- packLocation :: Maybe Text -> Bool -> URIAuth -> Location Abs -> URI
- unpackLocation :: URI -> (Maybe Text, Bool, URIAuth, Location Abs)
Classes
class MonadUrl base (m :: * -> *) | m -> base where Source #
Turns a Path
or Location
into a String
, where the rendering behavior
(relative, grounded and absolute) is encoded in the monad you use, much like
LoggingT
and NoLoggingT
from monad-logger.
Instances
Types
URL
Either a URI (which could include a hostname), or a relative url.
Relative Urls
newtype RelativeUrlT m a Source #
When printing a URL
generated by a Location
in this context,
they will always omit the hostname information and print path references relatively
(without ./
).
RelativeUrlT | |
|
Instances
type RelativeUrl = RelativeUrlT Identity Source #
Grounded Urls
newtype GroundedUrlT m a Source #
Grounded urls mean that, while omiting host information, paths start with
a /
, like /foo
.
GroundedUrlT | |
|
Instances
type GroundedUrl = GroundedUrlT Identity Source #
Absolute Urls
newtype AbsoluteUrlT m a Source #
Given a means to take an absolute location and turn it into an URI, make a monad used to
construct urls. You can use packLocation
to create the Location Abs -> URI
function.
AbsoluteUrlT | |
|
Instances
type AbsoluteUrl = AbsoluteUrlT Identity Source #