hyperbole-0.5.0: Interactive HTML apps using type-safe serverside Haskell
Safe HaskellSafe-Inferred
LanguageGHC2021

Web.Hyperbole.View

Synopsis

Documentation

newtype View c a Source #

Views are HTML fragments with a context

helloWorld :: View context ()
helloWorld =
  el "Hello World"

Constructors

View 

Fields

Instances

Instances details
HasViewId (View ctx :: Type -> Type) (ctx :: Type) Source # 
Instance details

Defined in Web.Hyperbole.HyperView.ViewId

Methods

viewId :: View ctx ctx Source #

Applicative (View ctx) Source # 
Instance details

Defined in Web.Hyperbole.View.Types

Methods

pure :: a -> View ctx a #

(<*>) :: View ctx (a -> b) -> View ctx a -> View ctx b #

liftA2 :: (a -> b -> c) -> View ctx a -> View ctx b -> View ctx c #

(*>) :: View ctx a -> View ctx b -> View ctx b #

(<*) :: View ctx a -> View ctx b -> View ctx a #

Functor (View c) Source # 
Instance details

Defined in Web.Hyperbole.View.Types

Methods

fmap :: (a -> b) -> View c a -> View c b #

(<$) :: a -> View c b -> View c a #

Monad (View ctx) Source # 
Instance details

Defined in Web.Hyperbole.View.Types

Methods

(>>=) :: View ctx a -> (a -> View ctx b) -> View ctx b #

(>>) :: View ctx a -> View ctx b -> View ctx b #

return :: a -> View ctx a #

IsString (View c ()) Source # 
Instance details

Defined in Web.Hyperbole.View.Types

Methods

fromString :: String -> View c () #

Attributable (View c a) Source # 
Instance details

Defined in Web.Hyperbole.View.Types

Methods

(@) :: View c a -> (Attributes (View c a) -> Attributes (View c a)) -> View c a #

modAttributes :: (Map Name AttValue -> Map Name AttValue) -> View c a -> View c a #

Styleable (View c a) Source # 
Instance details

Defined in Web.Hyperbole.View.Types

Methods

(~) :: View c a -> (CSS (View c a) -> CSS (View c a)) -> View c a #

modCSS :: ([Rule] -> [Rule]) -> View c a -> View c a #

Styleable (TableColumns c dt () -> View c ()) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

(~) :: (TableColumns c dt () -> View c ()) -> (CSS (TableColumns c dt () -> View c ()) -> CSS (TableColumns c dt () -> View c ())) -> TableColumns c dt () -> View c () #

modCSS :: ([Rule] -> [Rule]) -> (TableColumns c dt () -> View c ()) -> TableColumns c dt () -> View c () #

text :: Text -> View c () Source #

none :: View c () Source #

tag :: Text -> View c () -> View c () Source #

raw :: Text -> View c () Source #

addContext :: ctx -> View ctx () -> View c () Source #

context :: forall c. View c c Source #

modifyContext :: forall ctx0 ctx1. (ctx0 -> ctx1) -> View ctx1 () -> View ctx0 () Source #

newtype Table c a Source #

Constructors

Table (View c a) 

Instances

Instances details
Applicative (Table c) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

pure :: a -> Table c a #

(<*>) :: Table c (a -> b) -> Table c a -> Table c b #

liftA2 :: (a -> b -> c0) -> Table c a -> Table c b -> Table c c0 #

(*>) :: Table c a -> Table c b -> Table c b #

(<*) :: Table c a -> Table c b -> Table c a #

Functor (Table c) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

fmap :: (a -> b) -> Table c a -> Table c b #

(<$) :: a -> Table c b -> Table c a #

Monad (Table c) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

(>>=) :: Table c a -> (a -> Table c b) -> Table c b #

(>>) :: Table c a -> Table c b -> Table c b #

return :: a -> Table c a #

Styleable (Table c a) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

(~) :: Table c a -> (CSS (Table c a) -> CSS (Table c a)) -> Table c a #

modCSS :: ([Rule] -> [Rule]) -> Table c a -> Table c a #

newtype TableColumns c dt a Source #

Constructors

TableColumns (Eff '[State [TableColumn c dt]] a) 

Instances

Instances details
Applicative (TableColumns c dt) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

pure :: a -> TableColumns c dt a #

(<*>) :: TableColumns c dt (a -> b) -> TableColumns c dt a -> TableColumns c dt b #

liftA2 :: (a -> b -> c0) -> TableColumns c dt a -> TableColumns c dt b -> TableColumns c dt c0 #

(*>) :: TableColumns c dt a -> TableColumns c dt b -> TableColumns c dt b #

(<*) :: TableColumns c dt a -> TableColumns c dt b -> TableColumns c dt a #

Functor (TableColumns c dt) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

fmap :: (a -> b) -> TableColumns c dt a -> TableColumns c dt b #

(<$) :: a -> TableColumns c dt b -> TableColumns c dt a #

Monad (TableColumns c dt) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

(>>=) :: TableColumns c dt a -> (a -> TableColumns c dt b) -> TableColumns c dt b #

(>>) :: TableColumns c dt a -> TableColumns c dt b -> TableColumns c dt b #

return :: a -> TableColumns c dt a #

Styleable (TableColumns c dt () -> View c ()) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

(~) :: (TableColumns c dt () -> View c ()) -> (CSS (TableColumns c dt () -> View c ()) -> CSS (TableColumns c dt () -> View c ())) -> TableColumns c dt () -> View c () #

modCSS :: ([Rule] -> [Rule]) -> (TableColumns c dt () -> View c ()) -> TableColumns c dt () -> View c () #

newtype TableHead id a Source #

Constructors

TableHead (View id a) 

Instances

Instances details
Applicative (TableHead id) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

pure :: a -> TableHead id a #

(<*>) :: TableHead id (a -> b) -> TableHead id a -> TableHead id b #

liftA2 :: (a -> b -> c) -> TableHead id a -> TableHead id b -> TableHead id c #

(*>) :: TableHead id a -> TableHead id b -> TableHead id b #

(<*) :: TableHead id a -> TableHead id b -> TableHead id a #

Functor (TableHead id) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

fmap :: (a -> b) -> TableHead id a -> TableHead id b #

(<$) :: a -> TableHead id b -> TableHead id a #

Monad (TableHead id) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

(>>=) :: TableHead id a -> (a -> TableHead id b) -> TableHead id b #

(>>) :: TableHead id a -> TableHead id b -> TableHead id b #

return :: a -> TableHead id a #

Styleable (TableHead id a) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

(~) :: TableHead id a -> (CSS (TableHead id a) -> CSS (TableHead id a)) -> TableHead id a #

modCSS :: ([Rule] -> [Rule]) -> TableHead id a -> TableHead id a #

data TableColumn c dt Source #

Constructors

TableColumn 

Fields

newtype ListItem c a Source #

Constructors

ListItem (View c a) 

Instances

Instances details
Applicative (ListItem c) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

pure :: a -> ListItem c a #

(<*>) :: ListItem c (a -> b) -> ListItem c a -> ListItem c b #

liftA2 :: (a -> b -> c0) -> ListItem c a -> ListItem c b -> ListItem c c0 #

(*>) :: ListItem c a -> ListItem c b -> ListItem c b #

(<*) :: ListItem c a -> ListItem c b -> ListItem c a #

Functor (ListItem c) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

fmap :: (a -> b) -> ListItem c a -> ListItem c b #

(<$) :: a -> ListItem c b -> ListItem c a #

Monad (ListItem c) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

(>>=) :: ListItem c a -> (a -> ListItem c b) -> ListItem c b #

(>>) :: ListItem c a -> ListItem c b -> ListItem c b #

return :: a -> ListItem c a #

Styleable (ListItem c a) Source # 
Instance details

Defined in Web.Hyperbole.View.Tag

Methods

(~) :: ListItem c a -> (CSS (ListItem c a) -> CSS (ListItem c a)) -> ListItem c a #

modCSS :: ([Rule] -> [Rule]) -> ListItem c a -> ListItem c a #

pre :: Text -> View c () Source #

link :: URI -> View c () -> View c () Source #

A hyperlink to the given url

space :: View c () Source #

col :: View c () -> View c () Source #

row :: View c () -> View c () Source #

el :: View c () -> View c () Source #

script' :: ByteString -> View c () Source #

Embed raw script, escape '/script'

code :: Text -> View c () Source #

td :: View c () -> View c () Source #

table :: [dt] -> TableColumns c dt () -> View c () Source #

Create a type safe data table by specifying columns

data User = User {name :: Text, email :: Text}

usersTable :: [User] -> View c ()
usersTable us = do
  table us $ do
    tcol (th "Name" ~ hd) $ \u -> td ~ cell $ text u.name
    tcol (th "Email" ~ hd) $ \u -> td ~ cell $ text u.email
 where
  hd = cell . bold
  cell :: (Styleable h) => CSS h -> CSS h
  cell = pad 4 . border 1

img :: Text -> View c () Source #

meta :: View c () Source #

title :: Text -> View c () Source #

script :: Text -> View c () Source #

nav :: View c () -> View c () Source #

tcol :: forall dt c. TableHead c () -> (dt -> View c ()) -> TableColumns c dt () Source #

th :: View c () -> TableHead c () Source #

ol :: ListItem c () -> View c () Source #

List elements do not include any inherent styling but are useful for accessibility. See list.

ol id $ do
 let nums = list Decimal
 li nums "one"
 li nums "two"
 li nums "three"

ul :: ListItem c () -> View c () Source #

li :: View c () -> ListItem c () Source #