-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Painfully simple URL writing combinators -- @package urlpath @version 0.0.2 module UrlPath.Types -- | A GET parameter encoded in a Url. data GETParam GETParam :: !Text -> !Text -> GETParam -- | Key for a get parameter. key :: GETParam -> !Text -- | Value for the key. val :: GETParam -> !Text -- | Render a GET parameter pair. renderGETParam :: GETParam -> Text -- | A Url string - a target page and GET parameters. data UrlString UrlString :: !Text -> [GETParam] -> UrlString -- | Relative base file - eg) "foo.php" in -- "foo.php?bar=baz". target :: UrlString -> !Text -- | GET Parameters. params :: UrlString -> [GETParam] -- | Render a Url String simply - this is equivalent to -- expandRelative. renderUrlString :: UrlString -> Text -- | Lifts a target path with some GET parameter chunks into a -- UrlString. () :: Text -> (Text, Text) -> UrlString -- | Adds more GET parameters to a UrlString. (<&>) :: UrlString -> (Text, Text) -> UrlString -- | Render the Url String as relative expandRelative :: UrlString -> Text -- | Render the Url String as grounded expandGrounded :: UrlString -> Text -- | Render the Url String as absolute - getting the root from a -- MonadReader. expandAbsolute :: MonadReader Text m => UrlString -> m Text -- | 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"
--   
expandAbsoluteWith :: MonadReader a m => UrlString -> (a -> Text) -> m Text -- | 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. newtype RelativeUrlT m a RelativeUrlT :: (Text -> m a) -> RelativeUrlT m a runRelativeUrlT :: RelativeUrlT m a -> Text -> m a -- | 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. newtype RelativeUrl a RelativeUrl :: (Text -> a) -> RelativeUrl a runRelativeUrl :: RelativeUrl a -> Text -> a newtype GroundedUrlT m a GroundedUrlT :: (Text -> m a) -> GroundedUrlT m a runGroundedUrlT :: GroundedUrlT m a -> Text -> m a newtype GroundedUrl a GroundedUrl :: (Text -> a) -> GroundedUrl a runGroundedUrl :: GroundedUrl a -> Text -> a newtype AbsoluteUrlT m a AbsoluteUrlT :: (Text -> m a) -> AbsoluteUrlT m a runAbsoluteUrlT :: AbsoluteUrlT m a -> Text -> m a newtype AbsoluteUrl a AbsoluteUrl :: (Text -> a) -> AbsoluteUrl a runAbsoluteUrl :: AbsoluteUrl a -> Text -> a instance Show GETParam instance Eq GETParam instance Show UrlString instance Eq UrlString instance MonadReader Text AbsoluteUrl instance Monad AbsoluteUrl instance Applicative AbsoluteUrl instance Functor AbsoluteUrl instance Monad m => MonadReader Text (AbsoluteUrlT m) instance MonadTrans AbsoluteUrlT instance Monad m => Monad (AbsoluteUrlT m) instance Applicative f => Applicative (AbsoluteUrlT f) instance Functor f => Functor (AbsoluteUrlT f) instance MonadReader Text GroundedUrl instance Monad GroundedUrl instance Applicative GroundedUrl instance Functor GroundedUrl instance Monad m => MonadReader Text (GroundedUrlT m) instance MonadTrans GroundedUrlT instance Monad m => Monad (GroundedUrlT m) instance Applicative f => Applicative (GroundedUrlT f) instance Functor f => Functor (GroundedUrlT f) instance MonadReader Text RelativeUrl instance Monad RelativeUrl instance Applicative RelativeUrl instance Functor RelativeUrl instance Monad m => MonadReader Text (RelativeUrlT m) instance MonadTrans RelativeUrlT instance Monad m => Monad (RelativeUrlT m) instance Applicative f => Applicative (RelativeUrlT f) instance Functor f => Functor (RelativeUrlT f) module UrlPath -- | Convenience typeclass for a uniform interface into pure -- Reader-like monads. class MonadReader Text m => UrlReader (m :: * -> *) runUrlReader :: UrlReader m => m a -> Text -> a -- | Url takes an input type a, and returns a modality -- f around T.Text. class Monad m => Url a m renderUrl :: Url a m => a -> m Text instance Monad m => Url UrlString (AbsoluteUrlT m) instance Monad m => Url UrlString (GroundedUrlT m) instance Monad m => Url UrlString (RelativeUrlT m) instance Url UrlString AbsoluteUrl instance Url UrlString GroundedUrl instance Url UrlString RelativeUrl instance Url Text Identity instance UrlReader GroundedUrl instance UrlReader RelativeUrl instance UrlReader AbsoluteUrl instance UrlReader Identity instance MonadReader Text Identity