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 h m b = RelativeUrlT {
- runRelativeUrlT :: h -> m b
- type RelativeUrl h b = RelativeUrlT h Identity b
- newtype GroundedUrlT h m b = GroundedUrlT {
- runGroundedUrlT :: h -> m b
- type GroundedUrl h b = GroundedUrlT h Identity b
- newtype AbsoluteUrlT h m b = AbsoluteUrlT {
- runAbsoluteUrlT :: h -> m b
- type AbsoluteUrl h b = AbsoluteUrlT h Identity b
Documentation
A Url string - a "target" and GET parameters. We require IsString
and Monoid
so that construction can be convenient and generic, 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
restriction.
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 h m b Source
RelativeUrlT | |
|
(Monad m, IsString h) => MonadReader h (RelativeUrlT h m) | |
(Monad m, Monoid plain, IsString plain) => UrlReader plain (RelativeUrlT plain m) | |
(Monad m, Monoid plain, IsString plain) => Url plain (RelativeUrlT plain 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 h m) | |
type Result (RelativeUrlT plain m) = m |
type RelativeUrl h b = RelativeUrlT h Identity b Source
newtype GroundedUrlT h m b Source
GroundedUrlT | |
|
(Monad m, IsString h) => MonadReader h (GroundedUrlT h m) | |
(Monad m, Monoid plain, IsString plain) => UrlReader plain (GroundedUrlT plain m) | |
(Monad m, Monoid plain, IsString plain) => Url plain (GroundedUrlT plain m) | |
MonadTrans (GroundedUrlT h) | |
Monad m => Monad (GroundedUrlT h m) | |
Functor m => Functor (GroundedUrlT h m) | |
Applicative f => Applicative (GroundedUrlT h f) | |
MonadIO m => MonadIO (GroundedUrlT h m) | |
type Result (GroundedUrlT plain m) = m |
type GroundedUrl h b = GroundedUrlT h Identity b Source
newtype AbsoluteUrlT h m b Source
AbsoluteUrlT | |
|
(Monad m, IsString h) => MonadReader h (AbsoluteUrlT h m) | |
(Monad m, Monoid plain, IsString plain) => UrlReader plain (AbsoluteUrlT plain m) | |
(Monad m, Monoid plain, IsString plain) => Url plain (AbsoluteUrlT plain m) | |
MonadTrans (AbsoluteUrlT h) | |
Monad m => Monad (AbsoluteUrlT h m) | |
Functor m => Functor (AbsoluteUrlT h m) | |
Applicative f => Applicative (AbsoluteUrlT h f) | |
MonadIO m => MonadIO (AbsoluteUrlT h m) | |
type Result (AbsoluteUrlT plain m) = m |
type AbsoluteUrl h b = AbsoluteUrlT h Identity b Source