web-rep-0.7.0: representations of a web page

Safe HaskellNone
LanguageHaskell2010

Web.Rep.Html

Contents

Description

Key generators and miscellaneous html utilities.

Uses the lucid Html.

Synopsis

Documentation

class__ :: Text -> Attribute Source #

FIXME: A horrible hack to separate class id's

toText :: Html a -> Text Source #

Convert html to text

libCss :: Text -> Html () Source #

Convert a link to a css library from text to html.

>>> libCss "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">

libJs :: Text -> Html () Source #

Convert a link to a js library from text to html.

>>> libJs "https://code.jquery.com/jquery-3.3.1.slim.min.js"
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>

data HtmlT (m :: Type -> Type) a #

A monad transformer that generates HTML. Use the simpler Html type if you don't want to transform over some other monad.

Instances
MonadTrans HtmlT

Used for lift.

Instance details

Defined in Lucid.Base

Methods

lift :: Monad m => m a -> HtmlT m a #

MonadReader r m => MonadReader r (HtmlT m)

Since: lucid-2.9.7

Instance details

Defined in Lucid.Base

Methods

ask :: HtmlT m r #

local :: (r -> r) -> HtmlT m a -> HtmlT m a #

reader :: (r -> a) -> HtmlT m a #

MonadState s m => MonadState s (HtmlT m)

Since: lucid-2.9.7

Instance details

Defined in Lucid.Base

Methods

get :: HtmlT m s #

put :: s -> HtmlT m () #

state :: (s -> (a, s)) -> HtmlT m a #

MonadError e m => MonadError e (HtmlT m)

Since: lucid-2.9.9

Instance details

Defined in Lucid.Base

Methods

throwError :: e -> HtmlT m a #

catchError :: HtmlT m a -> (e -> HtmlT m a) -> HtmlT m a #

MonadWriter w m => MonadWriter w (HtmlT m)

Since: lucid-2.9.9

Instance details

Defined in Lucid.Base

Methods

writer :: (a, w) -> HtmlT m a #

tell :: w -> HtmlT m () #

listen :: HtmlT m a -> HtmlT m (a, w) #

pass :: HtmlT m (a, w -> w) -> HtmlT m a #

(Monad m, a ~ ()) => TermRaw Text (HtmlT m a)

Given children immediately, just use that and expect no attributes.

Instance details

Defined in Lucid.Base

Methods

termRaw :: Text -> Text -> HtmlT m a #

termRawWith :: Text -> [Attribute] -> Text -> HtmlT m a #

Monad m => Monad (HtmlT m)

Basically acts like Writer.

Instance details

Defined in Lucid.Base

Methods

(>>=) :: HtmlT m a -> (a -> HtmlT m b) -> HtmlT m b #

(>>) :: HtmlT m a -> HtmlT m b -> HtmlT m b #

return :: a -> HtmlT m a #

fail :: String -> HtmlT m a #

Functor m => Functor (HtmlT m)

Just re-uses Monad.

Instance details

Defined in Lucid.Base

Methods

fmap :: (a -> b) -> HtmlT m a -> HtmlT m b #

(<$) :: a -> HtmlT m b -> HtmlT m a #

MonadFix m => MonadFix (HtmlT m) 
Instance details

Defined in Lucid.Base

Methods

mfix :: (a -> HtmlT m a) -> HtmlT m a #

Applicative m => Applicative (HtmlT m)

Based on the monad instance.

Instance details

Defined in Lucid.Base

Methods

pure :: a -> HtmlT m a #

(<*>) :: HtmlT m (a -> b) -> HtmlT m a -> HtmlT m b #

liftA2 :: (a -> b -> c) -> HtmlT m a -> HtmlT m b -> HtmlT m c #

(*>) :: HtmlT m a -> HtmlT m b -> HtmlT m b #

(<*) :: HtmlT m a -> HtmlT m b -> HtmlT m a #

MonadIO m => MonadIO (HtmlT m)

If you want to use IO in your HTML generation.

Instance details

Defined in Lucid.Base

Methods

liftIO :: IO a -> HtmlT m a #

MFunctor HtmlT

Since: lucid-2.9.5

Instance details

Defined in Lucid.Base

Methods

hoist :: Monad m => (forall a. m a -> n a) -> HtmlT m b -> HtmlT n b #

(Applicative m, f ~ HtmlT m a) => Term [Attribute] (f -> HtmlT m a)

Given attributes, expect more child input.

Instance details

Defined in Lucid.Base

Methods

term :: Text -> [Attribute] -> f -> HtmlT m a #

termWith :: Text -> [Attribute] -> [Attribute] -> f -> HtmlT m a #

(Monad m, ToHtml f, a ~ ()) => TermRaw [Attribute] (f -> HtmlT m a)

Given attributes, expect more child input.

Instance details

Defined in Lucid.Base

Methods

termRaw :: Text -> [Attribute] -> f -> HtmlT m a #

termRawWith :: Text -> [Attribute] -> [Attribute] -> f -> HtmlT m a #

m ~ Identity => Show (HtmlT m a)

Just calls renderText.

Instance details

Defined in Lucid.Base

Methods

showsPrec :: Int -> HtmlT m a -> ShowS #

show :: HtmlT m a -> String #

showList :: [HtmlT m a] -> ShowS #

(Monad m, a ~ ()) => IsString (HtmlT m a)

We pack it via string. Could possibly encode straight into a builder. That might be faster.

Instance details

Defined in Lucid.Base

Methods

fromString :: String -> HtmlT m a #

(a ~ (), Applicative m) => Semigroup (HtmlT m a)

Since: lucid-2.9.7

Instance details

Defined in Lucid.Base

Methods

(<>) :: HtmlT m a -> HtmlT m a -> HtmlT m a #

sconcat :: NonEmpty (HtmlT m a) -> HtmlT m a #

stimes :: Integral b => b -> HtmlT m a -> HtmlT m a #

(a ~ (), Applicative m) => Monoid (HtmlT m a)

Monoid is right-associative, a la the Builder in it.

Instance details

Defined in Lucid.Base

Methods

mempty :: HtmlT m a #

mappend :: HtmlT m a -> HtmlT m a -> HtmlT m a #

mconcat :: [HtmlT m a] -> HtmlT m a #

(a ~ (), m ~ Identity) => ToHtml (HtmlT m a)

Since: lucid-2.9.8

Instance details

Defined in Lucid.Base

Methods

toHtml :: Monad m0 => HtmlT m a -> HtmlT m0 () #

toHtmlRaw :: Monad m0 => HtmlT m a -> HtmlT m0 () #

Functor m => With (HtmlT m a -> HtmlT m a)

For the contentful elements: div_

Instance details

Defined in Lucid.Base

Methods

with :: (HtmlT m a -> HtmlT m a) -> [Attribute] -> HtmlT m a -> HtmlT m a #

Functor m => With (HtmlT m a)

For the contentless elements: br_

Instance details

Defined in Lucid.Base

Methods

with :: HtmlT m a -> [Attribute] -> HtmlT m a #

Applicative m => Term (HtmlT m a) (HtmlT m a)

Given children immediately, just use that and expect no attributes.

Instance details

Defined in Lucid.Base

Methods

term :: Text -> HtmlT m a -> HtmlT m a #

termWith :: Text -> [Attribute] -> HtmlT m a -> HtmlT m a #

type Html = HtmlT Identity #

Simple HTML builder type. Defined in terms of HtmlT. Check out that type for instance information.

Simple use-cases will just use this type. But if you want to transformer over Reader or something, you can go and use HtmlT.

Orphan instances

ToHtml Bool Source # 
Instance details

Methods

toHtml :: Monad m => Bool -> HtmlT m () #

toHtmlRaw :: Monad m => Bool -> HtmlT m () #

ToHtml Double Source #

FIXME: `ToHtml a` is used throughout, mostly because `Show a` gives ""text"" for show "text", and hilarity ensues when rendering this to a web page, and I couldn't work out how to properly get around this.

Hence, these orphans.

Instance details

Methods

toHtml :: Monad m => Double -> HtmlT m () #

toHtmlRaw :: Monad m => Double -> HtmlT m () #

ToHtml Int Source # 
Instance details

Methods

toHtml :: Monad m => Int -> HtmlT m () #

toHtmlRaw :: Monad m => Int -> HtmlT m () #

ToHtml () Source # 
Instance details

Methods

toHtml :: Monad m => () -> HtmlT m () #

toHtmlRaw :: Monad m => () -> HtmlT m () #

ToHtml a => ToHtml [a] Source # 
Instance details

Methods

toHtml :: Monad m => [a] -> HtmlT m () #

toHtmlRaw :: Monad m => [a] -> HtmlT m () #