Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
UrlPath.Types
- data GETParam = GETParam {}
- renderGETParam :: GETParam -> Text
- data UrlString = UrlString {}
- renderUrlString :: UrlString -> Text
- (<?>) :: Text -> (Text, Text) -> UrlString
- (<&>) :: UrlString -> (Text, Text) -> UrlString
- expandRelative :: UrlString -> Text
- expandGrounded :: UrlString -> Text
- expandAbsolute :: MonadReader Text m => UrlString -> m Text
- expandAbsoluteWith :: MonadReader a m => UrlString -> (a -> Text) -> m Text
- newtype RelativeUrlT m a = RelativeUrlT {
- runRelativeUrlT :: Text -> m a
- newtype RelativeUrl a = RelativeUrl {
- runRelativeUrl :: Text -> a
- newtype GroundedUrlT m a = GroundedUrlT {
- runGroundedUrlT :: Text -> m a
- newtype GroundedUrl a = GroundedUrl {
- runGroundedUrl :: Text -> a
- newtype AbsoluteUrlT m a = AbsoluteUrlT {
- runAbsoluteUrlT :: Text -> m a
- newtype AbsoluteUrl a = AbsoluteUrl {
- runAbsoluteUrl :: Text -> a
Documentation
A GET parameter encoded in a Url.
renderGETParam :: GETParam -> Text Source
Render a GET parameter pair.
A Url string - a target page and GET parameters.
Constructors
UrlString | |
Instances
Eq UrlString | |
Show UrlString | |
Url UrlString AbsoluteUrl | |
Url UrlString GroundedUrl | |
Url UrlString RelativeUrl | |
Monad m => Url UrlString (AbsoluteUrlT m) | |
Monad m => Url UrlString (GroundedUrlT m) | |
Monad m => Url UrlString (RelativeUrlT m) |
renderUrlString :: UrlString -> Text Source
Render a Url String simply - this is equivalent to expandRelative
.
Lifts a target path with some GET parameter chunks into a UrlString
.
Adds more GET parameters to a UrlString
.
expandRelative :: UrlString -> Text Source
Render the Url String as relative
expandGrounded :: UrlString -> Text Source
Render the Url String as grounded
expandAbsolute :: MonadReader Text m => UrlString -> m Text Source
Render the Url String as absolute - getting the root from a MonadReader.
expandAbsoluteWith :: MonadReader a m => UrlString -> (a -> Text) -> m Text Source
Render the Url String as absolute, but with your own configuration type.
data SiteConfig = SiteConfig { host :: T.Text , cdnHost :: T.Text } deriving (Show, Eq) foo :: HtmlT (Reader SiteConfig) () foo = do url <- lift $ expandAbsoluteWith ("foo.php" <?> ("bar","baz")) host script_ [src_ url] "" bar :: LT.Text bar = (runReader (runTextT foo)) $ SiteConfig "example.com" "cdn.example.com"
newtype RelativeUrlT m a Source
Rendering mode transformer. This isn't an instance of UrlReader
- to use,
simple lift
as many levels as you need:
foo :: Monad m => HtmlT (RelativeUrlT m) () foo = do url <- lift $ renderUrl $ "foo.php" <?> ("bar","baz") script_ [src_ url] ""
When rendering foo
, simply use the Transformer's run
function to convert
it to a reader:
bar :: Monad m => m LT.Text bar = (runRelativeUrlT (renderTextT foo)) "example.com"
It is generally simpler (but more restrictive) to use the non-transformer variety.
Constructors
RelativeUrlT | |
Fields
|
Instances
MonadTrans RelativeUrlT | |
Monad m => MonadReader Text (RelativeUrlT m) | |
Monad m => Url Text (RelativeUrlT m) | |
Monad m => Url UrlString (RelativeUrlT m) | |
Monad m => Monad (RelativeUrlT m) | |
Functor f => Functor (RelativeUrlT f) | |
Applicative f => Applicative (RelativeUrlT f) |
newtype RelativeUrl a Source
Concrete Monad for automatically coercing HtmlT's to use a mode of Url rendering (relative, grounded, or absolute).
foo :: HtmlT RelativeUrl () foo = do url <- lift $ renderUrl $ "foo.php" <?> ("bar","baz") script_ [src_ url] ""
when rendering these simple monads for automatic conversion via coercion, use
the runUrlReader
member function of the UrlReader
typeclass:
bar :: LT.Text bar = (runUrlReader (renderTextT foo)) "example.com"
To change the mode of rendering, simple change the coerced type of foo
.
Constructors
RelativeUrl | |
Fields
|
newtype GroundedUrlT m a Source
Constructors
GroundedUrlT | |
Fields
|
Instances
MonadTrans GroundedUrlT | |
Monad m => MonadReader Text (GroundedUrlT m) | |
Monad m => Url Text (GroundedUrlT m) | |
Monad m => Url UrlString (GroundedUrlT m) | |
Monad m => Monad (GroundedUrlT m) | |
Functor f => Functor (GroundedUrlT f) | |
Applicative f => Applicative (GroundedUrlT f) |
newtype GroundedUrl a Source
Constructors
GroundedUrl | |
Fields
|
newtype AbsoluteUrlT m a Source
Constructors
AbsoluteUrlT | |
Fields
|
Instances
MonadTrans AbsoluteUrlT | |
Monad m => MonadReader Text (AbsoluteUrlT m) | |
Monad m => Url Text (AbsoluteUrlT m) | |
Monad m => Url UrlString (AbsoluteUrlT m) | |
Monad m => Monad (AbsoluteUrlT m) | |
Functor f => Functor (AbsoluteUrlT f) | |
Applicative f => Applicative (AbsoluteUrlT f) |
newtype AbsoluteUrl a Source
Constructors
AbsoluteUrl | |
Fields
|