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 plain, Monoid plain) => UrlString plain -> plain
- expandGrounded :: (IsString plain, Monoid plain) => UrlString plain -> plain
- expandAbsolute :: (MonadReader plain m, IsString plain, Monoid plain) => UrlString plain -> m plain
- expandAbsoluteWith :: (MonadReader a m, IsString plain, Monoid plain) => UrlString plain -> (a -> plain) -> m plain
- newtype RelativeUrlT m h b = RelativeUrlT {
- runRelativeUrlT :: h -> m b
- newtype RelativeUrl h a = RelativeUrl {
- runRelativeUrl :: h -> a
- newtype GroundedUrlT m h b = GroundedUrlT {
- runGroundedUrlT :: h -> m b
- newtype GroundedUrl h a = GroundedUrl {
- runGroundedUrl :: h -> a
- newtype AbsoluteUrlT m h b = AbsoluteUrlT {
- runAbsoluteUrlT :: h -> m b
- 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 plain, Monoid plain) => UrlString plain -> plain Source
Render the Url String as relative
expandGrounded :: (IsString plain, Monoid plain) => UrlString plain -> plain Source
Render the Url String as grounded
expandAbsolute :: (MonadReader plain m, IsString plain, Monoid plain) => UrlString plain -> m plain 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 plain, Monoid plain) => UrlString plain -> (a -> plain) -> m plain 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 h b 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, Monoid plain, IsString plain) => Url plain (RelativeUrlT m) | |
(Monad m, IsString h) => MonadReader h (RelativeUrlT m h) | |
Monad m => Monad (RelativeUrlT m h) | |
Functor m => Functor (RelativeUrlT m h) | |
Applicative f => Applicative (RelativeUrlT f h) |
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 | |
|
(Monoid plain, IsString plain) => UrlReader plain RelativeUrl | |
(Monoid plain, IsString plain) => Url plain RelativeUrl | |
IsString a => MonadReader a (RelativeUrl a) | |
Monad (RelativeUrl h) | |
Functor (RelativeUrl h) | |
Applicative (RelativeUrl h) |
newtype GroundedUrlT m h b Source
GroundedUrlT | |
|
(Monad m, Monoid plain, IsString plain) => Url plain (GroundedUrlT m) | |
(Monad m, IsString h) => MonadReader h (GroundedUrlT m h) | |
Monad m => Monad (GroundedUrlT m h) | |
Functor f => Functor (GroundedUrlT f h) | |
Applicative f => Applicative (GroundedUrlT f h) |
newtype GroundedUrl h a Source
GroundedUrl | |
|
(Monoid plain, IsString plain) => UrlReader plain GroundedUrl | |
(Monoid plain, IsString plain) => Url plain GroundedUrl | |
IsString a => MonadReader a (GroundedUrl a) | |
Monad (GroundedUrl h) | |
Functor (GroundedUrl h) | |
Applicative (GroundedUrl h) |
newtype AbsoluteUrlT m h b Source
AbsoluteUrlT | |
|
(Monad m, Monoid plain, IsString plain) => Url plain (AbsoluteUrlT m) | |
(Monad m, IsString h) => MonadReader h (AbsoluteUrlT m h) | |
Monad m => Monad (AbsoluteUrlT m h) | |
Functor f => Functor (AbsoluteUrlT f h) | |
Applicative f => Applicative (AbsoluteUrlT f h) |
newtype AbsoluteUrl h a Source
AbsoluteUrl | |
|
(Monoid plain, IsString plain) => UrlReader plain AbsoluteUrl | Hand-off host prepending to the MonadReader instance |
(Monoid plain, IsString plain) => Url plain AbsoluteUrl | |
IsString a => MonadReader a (AbsoluteUrl a) | |
Monad (AbsoluteUrl h) | |
Functor (AbsoluteUrl h) | |
Applicative (AbsoluteUrl h) |