Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
- data UrlString a where
- showUrlString :: UrlString a -> a
- (<?>) :: (IsString a, Monoid a) => a -> (a, a) -> UrlString a
- (<&>) :: (IsString a, Monoid a) => UrlString a -> (a, a) -> UrlString a
- expandRelative :: (IsString a, Monoid a) => UrlString a -> a
- expandGrounded :: (IsString a, Monoid a) => UrlString a -> a
- expandAbsolute :: (MonadReader a m, IsString a, Monoid a) => UrlString a -> m a
- expandAbsoluteWith :: (MonadReader a m, IsString a, Monoid a) => UrlString a -> (a -> a) -> m a
- newtype RelativeUrlT h m a = RelativeUrlT {
- runRelativeUrlT :: h -> m a
- newtype RelativeUrl h a = RelativeUrl {
- runRelativeUrl :: h -> a
- newtype GroundedUrlT h m a = GroundedUrlT {
- runGroundedUrlT :: h -> m a
- newtype GroundedUrl h a = GroundedUrl {
- runGroundedUrl :: h -> a
- newtype AbsoluteUrlT h m a = AbsoluteUrlT {
- runAbsoluteUrlT :: h -> m a
- newtype AbsoluteUrl h a = AbsoluteUrl {
- runAbsoluteUrl :: h -> a
Documentation
A Url string - a target page and GET parameters. We only require a
constraint of IsString
so that construction can be convenient, but
rendering will require a monomorphic type.
showUrlString :: UrlString a -> a Source
We choose to not provide a Show
instance for UrlString
to evade the
String
demand.
Lifts a raw target path and a GET parameter pair into a UrlString
.
Adds another GET parameter pair to a UrlString
.
expandRelative :: (IsString a, Monoid a) => UrlString a -> a Source
Render the Url String as relative
expandGrounded :: (IsString a, Monoid a) => UrlString a -> a Source
Render the Url String as grounded
expandAbsolute :: (MonadReader a m, IsString a, Monoid a) => UrlString a -> m a Source
Render the Url String as absolute - getting the root from a MonadReader
context. The Monoid
instance will be decided monomorphically, therefore a
type signature will be needed when ran.
expandAbsoluteWith :: (MonadReader a m, IsString a, Monoid a) => UrlString a -> (a -> a) -> m a 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 h 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 path <- lift $ url $ "foo.php" <?> ("bar","baz") script_ [src_ path] ""
When rendering foo
, simply use the Transformer's run
function to convert
it to a reader:
bar :: ( Monad m, IsString a, Monoid a ) => m a bar = (runRelativeUrlT (renderTextT foo)) "example.com"
RelativeUrlT | |
|
(Monad m, IsString a) => MonadReader a (RelativeUrlT a m) | |
(Monad m, Monoid a, IsString a) => Url a (RelativeUrlT a m) | |
MonadTrans (RelativeUrlT h) | |
Monad m => Monad (RelativeUrlT h m) | |
Functor m => Functor (RelativeUrlT h m) | |
Applicative f => Applicative (RelativeUrlT h f) | |
MonadIO m => MonadIO (RelativeUrlT a m) |
newtype RelativeUrl h 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 path <- lift $ url $ "foo.php" <?> ("bar","baz") script_ [src_ path] ""
when running the monad reader, use the runUrlReader
member function of the
UrlReader
typeclass:
bar :: ( IsString a, Monoid a ) => a bar = (runUrlReader (renderTextT foo)) "example.com"
To change the deployment sheme, simply coerce the environment monad in foo
.
RelativeUrl | |
|
IsString a => MonadReader a (RelativeUrl a) | |
(Monoid a, IsString a) => UrlReader a (RelativeUrl a) | |
(Monoid a, IsString a) => Url a (RelativeUrl a) | |
Monad (RelativeUrl h) | |
Functor (RelativeUrl h) | |
Applicative (RelativeUrl h) |
newtype GroundedUrlT h m a Source
GroundedUrlT | |
|
(Monad m, IsString a) => MonadReader a (GroundedUrlT a m) | |
(Monad m, Monoid a, IsString a) => Url a (GroundedUrlT a m) | |
MonadTrans (GroundedUrlT h) | |
Monad m => Monad (GroundedUrlT h m) | |
Functor f => Functor (GroundedUrlT h f) | |
Applicative f => Applicative (GroundedUrlT h f) | |
MonadIO m => MonadIO (GroundedUrlT a m) |
newtype GroundedUrl h a Source
GroundedUrl | |
|
IsString a => MonadReader a (GroundedUrl a) | |
(Monoid a, IsString a) => UrlReader a (GroundedUrl a) | |
(Monoid a, IsString a) => Url a (GroundedUrl a) | |
Monad (GroundedUrl h) | |
Functor (GroundedUrl h) | |
Applicative (GroundedUrl h) |
newtype AbsoluteUrlT h m a Source
AbsoluteUrlT | |
|
(Monad m, IsString a) => MonadReader a (AbsoluteUrlT a m) | |
(Monad m, Monoid a, IsString a) => Url a (AbsoluteUrlT a m) | |
MonadTrans (AbsoluteUrlT h) | |
Monad m => Monad (AbsoluteUrlT h m) | |
Functor f => Functor (AbsoluteUrlT h f) | |
Applicative f => Applicative (AbsoluteUrlT h f) | |
MonadIO m => MonadIO (AbsoluteUrlT a m) |
newtype AbsoluteUrl h a Source
AbsoluteUrl | |
|
IsString a => MonadReader a (AbsoluteUrl a) | |
(Monoid a, IsString a) => UrlReader a (AbsoluteUrl a) | Hand-off host prepending to the MonadReader instance |
(Monoid a, IsString a) => Url a (AbsoluteUrl a) | |
Monad (AbsoluteUrl h) | |
Functor (AbsoluteUrl h) | |
Applicative (AbsoluteUrl h) |