-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | representations of a web page -- -- An applicative-based, shared-data representation of a web page. @package web-rep @version 0.2.0 module Web.Page.Html -- | FIXME: A horrible hack to separate class id's class__ :: Text -> Attribute -- | Convert html to text toText :: Html a -> Text -- | name supply for html elements genName :: MonadState Int m => m Text -- | sometimes a number doesn't work properly in html (or js???), and an -- alpha prefix seems to help genNamePre :: MonadState Int m => Text -> m Text -- | Convert a link to a css library from text to html. >>> libCss -- "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" -- href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" -- rel="stylesheet" libCss :: Text -> Html () -- | Convert a link to a js library from text to html. >>> libJs -- "https://code.jquery.com/jquery-3.3.1.slim.min.js" -- src="https://code.jquery.com/jquery-3.3.1.slim.min.js"/script libJs :: Text -> Html () -- | convert from #xxxxxx to PixelRGB8 fromHex :: Parser PixelRGB8 -- | convert from PixelRGB8 to #xxxxxx toHex :: PixelRGB8 -> Text -- | 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. type Html = HtmlT Identity instance Lucid.Base.ToHtml GHC.Types.Double instance Lucid.Base.ToHtml GHC.Types.Bool instance Lucid.Base.ToHtml GHC.Types.Int instance Lucid.Base.ToHtml Codec.Picture.Types.PixelRGB8 instance Lucid.Base.ToHtml () module Web.Page.Html.Input -- | something that might exist on a web page and be a front-end input to -- computations. data Input a Input :: a -> Maybe Text -> Text -> InputType -> Input a -- | various types of Inputs, that encapsulate practical bootstrap class -- functionality data InputType Slider :: [Attribute] -> InputType TextBox :: InputType TextArea :: Int -> InputType ColorPicker :: InputType ChooseFile :: InputType Dropdown :: [Text] -> InputType DropdownSum :: [Text] -> InputType Datalist :: [Text] -> Text -> InputType Checkbox :: Bool -> InputType Toggle :: Bool -> Maybe Text -> InputType Button :: InputType -- | toggle show/hide scriptToggleShow :: Monad m => Text -> Text -> HtmlT m () instance GHC.Generics.Generic (Web.Page.Html.Input.Input a) instance GHC.Show.Show a => GHC.Show.Show (Web.Page.Html.Input.Input a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Web.Page.Html.Input.Input a) instance GHC.Generics.Generic Web.Page.Html.Input.InputType instance GHC.Show.Show Web.Page.Html.Input.InputType instance GHC.Classes.Eq Web.Page.Html.Input.InputType instance Lucid.Base.ToHtml a => Lucid.Base.ToHtml (Web.Page.Html.Input.Input a) module Web.Page.Types -- | Components of a web page. -- -- A web page typically can take many forms but still be the same web -- page. For example, css can be linked to in a separate file, or can be -- inline within html, but still be the same css. This type represents -- the practical components of what makes up a web page. data Page Page :: [Html ()] -> [Html ()] -> PageCss -> PageJs -> PageJs -> Html () -> Html () -> Page -- | css library links [libsCss] :: Page -> [Html ()] -- | javascript library links [libsJs] :: Page -> [Html ()] -- | css [cssBody] :: Page -> PageCss -- | javascript with global scope [jsGlobal] :: Page -> PageJs -- | javascript included within the onLoad function [jsOnLoad] :: Page -> PageJs -- | html within the header [htmlHeader] :: Page -> Html () -- | body html [htmlBody] :: Page -> Html () -- | Configuration of the rendering of a web page data PageConfig PageConfig :: PageConcerns -> PageStructure -> PageRender -> Concerns FilePath -> [FilePath] -> PageConfig [concerns] :: PageConfig -> PageConcerns [structure] :: PageConfig -> PageStructure [pageRender] :: PageConfig -> PageRender [filenames] :: PageConfig -> Concerns FilePath [localdirs] :: PageConfig -> [FilePath] defaultPageConfig :: FilePath -> PageConfig -- | A web page typically is composed of css, javascript and html -- -- Concerns abstracts this compositional feature of a web page. data Concerns a Concerns :: a -> a -> a -> Concerns a [cssConcern] :: Concerns a -> a [jsConcern] :: Concerns a -> a [htmlConcern] :: Concerns a -> a -- | the common file suffixes of the three concerns suffixes :: Concerns FilePath -- | create filenames for each Concern element. concernNames :: FilePath -> FilePath -> Concerns FilePath -- | Is the rendering to include all Concerns or be separated? data PageConcerns Inline :: PageConcerns Separated :: PageConcerns -- | Various ways that a Html file can be structured. data PageStructure HeaderBody :: PageStructure Headless :: PageStructure Snippet :: PageStructure Svg :: PageStructure -- | Post-processing of page concerns data PageRender Pretty :: PageRender Minified :: PageRender NoPost :: PageRender -- | The Css context is used to collect style rules which are -- mappings from selectors to style properties. The Css type is a -- computation in the StyleM monad that just collects and doesn't -- return anything. type Css = StyleM () -- | unifies css as a Clay.Css and css as Text data PageCss PageCss :: Css -> PageCss PageCssText :: Text -> PageCss -- | render Css as text renderCss :: Css -> Text -- | render PageCss as text renderPageCss :: PageRender -> PageCss -> Text -- | wrapper for JSAST newtype JS JS :: JSAST -> JS [unJS] :: JS -> JSAST -- | unify JSStatement javascript and text-rendered script data PageJs PageJs :: JS -> PageJs PageJsText :: Text -> PageJs -- | wrap js in standard DOM window loader onLoad :: PageJs -> PageJs -- | render PageJs as text renderPageJs :: PageRender -> PageJs -> Text -- | convert text to JS parseJs :: Text -> JS -- | render JS as text renderJs :: JS -> Text -- | Abstracted message event element data Element Element :: Text -> Text -> Element [element] :: Element -> Text [value] :: Element -> Text data RepF r a Rep :: r -> (HashMap Text Text -> (HashMap Text Text, Either Text a)) -> RepF r a [rep] :: RepF r a -> r [make] :: RepF r a -> HashMap Text Text -> (HashMap Text Text, Either Text a) type Rep a = RepF (Html ()) a oneRep :: (Monad m, MonadIO m) => Rep a -> (Rep a -> HashMap Text Text -> m ()) -> StateT (HashMap Text Text) m (HashMap Text Text, Either Text a) newtype SharedRepF m r a SharedRep :: StateT (Int, HashMap Text Text) m (RepF r a) -> SharedRepF m r a [unrep] :: SharedRepF m r a -> StateT (Int, HashMap Text Text) m (RepF r a) type SharedRep m a = SharedRepF m (Html ()) a -- | compute the initial state of a SharedRep and then run a single action -- (testing) runOnce :: Monad m => SharedRep m a -> (Html () -> HashMap Text Text -> m ()) -> m (HashMap Text Text, Either Text a) -- | compute the initial state of a SharedRep (testing) zeroState :: Monad m => SharedRep m a -> m (Html (), (HashMap Text Text, Either Text a)) instance GHC.Base.Functor m => GHC.Base.Functor (Web.Page.Types.SharedRepF m r) instance GHC.Base.Functor (Web.Page.Types.RepF r) instance GHC.Generics.Generic Web.Page.Types.Element instance GHC.Show.Show Web.Page.Types.Element instance GHC.Classes.Eq Web.Page.Types.Element instance GHC.Generics.Generic Web.Page.Types.Page instance GHC.Show.Show Web.Page.Types.Page instance GHC.Generics.Generic Web.Page.Types.PageJs instance GHC.Show.Show Web.Page.Types.PageJs instance GHC.Classes.Eq Web.Page.Types.PageJs instance GHC.Generics.Generic Web.Page.Types.JS instance GHC.Classes.Eq Web.Page.Types.JS instance GHC.Show.Show Web.Page.Types.JS instance GHC.Generics.Generic Web.Page.Types.PageCss instance GHC.Generics.Generic Web.Page.Types.PageConfig instance GHC.Classes.Eq Web.Page.Types.PageConfig instance GHC.Show.Show Web.Page.Types.PageConfig instance GHC.Generics.Generic Web.Page.Types.PageRender instance GHC.Classes.Eq Web.Page.Types.PageRender instance GHC.Show.Show Web.Page.Types.PageRender instance GHC.Generics.Generic Web.Page.Types.PageStructure instance GHC.Classes.Eq Web.Page.Types.PageStructure instance GHC.Show.Show Web.Page.Types.PageStructure instance GHC.Generics.Generic Web.Page.Types.PageConcerns instance GHC.Classes.Eq Web.Page.Types.PageConcerns instance GHC.Show.Show Web.Page.Types.PageConcerns instance GHC.Generics.Generic (Web.Page.Types.Concerns a) instance Data.Traversable.Traversable Web.Page.Types.Concerns instance Data.Foldable.Foldable Web.Page.Types.Concerns instance GHC.Show.Show a => GHC.Show.Show (Web.Page.Types.Concerns a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Web.Page.Types.Concerns a) instance GHC.Base.Functor m => Data.Bifunctor.Bifunctor (Web.Page.Types.SharedRepF m) instance GHC.Base.Monad m => Data.Biapplicative.Biapplicative (Web.Page.Types.SharedRepF m) instance (GHC.Base.Monad m, GHC.Base.Monoid r) => GHC.Base.Applicative (Web.Page.Types.SharedRepF m r) instance GHC.Base.Semigroup r => GHC.Base.Semigroup (Web.Page.Types.RepF r a) instance (GHC.Base.Monoid a, GHC.Base.Monoid r) => GHC.Base.Monoid (Web.Page.Types.RepF r a) instance Data.Bifunctor.Bifunctor Web.Page.Types.RepF instance Data.Biapplicative.Biapplicative Web.Page.Types.RepF instance GHC.Base.Monoid r => GHC.Base.Applicative (Web.Page.Types.RepF r) instance Data.Aeson.Types.ToJSON.ToJSON Web.Page.Types.Element instance Data.Aeson.Types.FromJSON.FromJSON Web.Page.Types.Element instance GHC.Base.Semigroup Web.Page.Types.Page instance GHC.Base.Monoid Web.Page.Types.Page instance GHC.Base.Semigroup Web.Page.Types.PageJs instance GHC.Base.Monoid Web.Page.Types.PageJs instance GHC.Base.Semigroup Web.Page.Types.JS instance GHC.Base.Monoid Web.Page.Types.JS instance GHC.Show.Show Web.Page.Types.PageCss instance GHC.Base.Semigroup Web.Page.Types.PageCss instance GHC.Base.Monoid Web.Page.Types.PageCss instance GHC.Base.Functor Web.Page.Types.Concerns instance GHC.Base.Applicative Web.Page.Types.Concerns -- | Page rendering module Web.Page.Render -- | Render a Page with the default configuration into Html. renderPage :: Page -> Html () -- | Render a Page into css text, js text and html. renderPageWith :: PageConfig -> Page -> (Text, Text, Html ()) -- | Render a Page into Html. renderPageHtmlWith :: PageConfig -> Page -> Html () -- | Render a Page as Text. renderPageAsText :: PageConfig -> Page -> Concerns Text -- | Render Page concerns to files. renderPageToFile :: FilePath -> PageConfig -> Page -> IO () -- | Render a page to just a Html file. renderPageHtmlToFile :: FilePath -> PageConfig -> Page -> IO () module Web.Page.Server -- | serve a Page via a ScottyM servePageWith :: RoutePattern -> PageConfig -> Page -> ScottyM () module Web.Page.Bridge -- | componentry to kick off a javascript-bridge enabled page bridgePage :: Page -- | append to a container and run any embedded scripts append :: Engine -> Text -> Text -> IO () -- | replace a container and run any embedded scripts replace :: Engine -> Text -> Text -> IO () -- | The javascript bridge continuation. bridge :: Engine -> Cont_ IO Value -- | send css, js and html over the bridge sendConcerns :: Engine -> Text -> Concerns Text -> IO () -- | An Engine is a handle to a specific JavaScript engine data Engine -- | This accepts WebSocket requests, calls the callback with an -- Engine that can be used to access JavaScript. start :: (Engine -> IO ()) -> Application -> Application -- | The WAI application. -- -- Note that, since WAI 3.0, this type is structured in continuation -- passing style to allow for proper safe resource handling. This was -- handled in the past via other means (e.g., ResourceT). As a -- demonstration: -- --
--   app :: Application
--   app req respond = bracket_
--       (putStrLn "Allocating scarce resource")
--       (putStrLn "Cleaning up")
--       (respond $ responseLBS status200 [] "Hello World")
--   
type Application = Request -> Response -> IO ResponseReceived -> IO ResponseReceived -- | consume an Element using a Committer and a Value continuation valueConsume :: s -> (Element -> s -> s) -> Cont IO (Committer IO (Either Text s)) -> Cont_ IO Value -> IO s -- | consume shared values using a step function, a continuation committer, -- and a Value continuation. sharedConsume :: (s -> (s, Either Text b)) -> s -> (Element -> s -> s) -> Cont IO (Committer IO (Either Text (s, Either Text b))) -> Cont_ IO Value -> IO s -- | process a list of Values runList :: Monad m => SharedRep m a -> [Value] -> m [Either Text (HashMap Text Text, Either Text a)] -- | run a SharedRep using an initial state, a step function that consumes -- the shared model, and a value continuation runOnEvent :: SharedRep IO a -> (Rep a -> StateT (Int, HashMap Text Text) IO ()) -> (Either Text (HashMap Text Text, Either Text a) -> IO ()) -> Cont_ IO Value -> IO (HashMap Text Text) -- | create Wai Middleware for a SharedRepF providing an initialiser -- and action on events midShared :: () => SharedRep IO a -> (Engine -> Rep a -> StateT (HashMap Text Text) IO ()) -> (Engine -> Either Text (HashMap Text Text, Either Text a) -> IO ()) -> Application -> Application -- | some bootstrap assets module Web.Page.Bootstrap -- | A page containing all the bootstrap needs for a web page. bootstrapPage :: Page -- | wrap some Html with the bootstrap card class cardify :: (Html (), [Attribute]) -> Maybe Text -> (Html (), [Attribute]) -> Html () -- | wrap some html with a classed div divClass_ :: Text -> Html () -> Html () -- | create a bootstrapped accordian class accordion :: MonadState Int m => Text -> Maybe Text -> [(Text, Html ())] -> m (Html ()) -- | create a bootstrapped accordian class accordionChecked :: MonadState Int m => Text -> [(Text, Html (), Html ())] -> m (Html ()) accordionCardChecked :: Bool -> Text -> Text -> Text -> Text -> Html () -> Html () -> Html () -- | This version of accordion runs a local state for naming, and will -- cause name clashes if the prefix is not unique. accordion_ :: Text -> Maybe Text -> [(Text, Html ())] -> Html () module Web.Page.SharedReps -- | create a sharedRep from an Input repInput :: (Monad m, ToHtml a) => Parser a -> (a -> Text) -> Input a -> a -> SharedRep m a -- | does not put a value into the HashMap on instantiation, consumes the -- value when found in the HashMap, and substitutes a default on lookup -- failure repMessage :: (Monad m, ToHtml a) => Parser a -> (a -> Text) -> Input a -> a -> a -> SharedRep m a sliderI :: (Monad m, ToHtml a, Integral a, Show a) => Maybe Text -> a -> a -> a -> a -> SharedRep m a slider :: Monad m => Maybe Text -> Double -> Double -> Double -> Double -> SharedRep m Double dropdown :: (Monad m, ToHtml a) => Parser a -> (a -> Text) -> Maybe Text -> [Text] -> a -> SharedRep m a datalist :: Monad m => Maybe Text -> [Text] -> Text -> Text -> SharedRep m Text dropdownSum :: (Monad m, ToHtml a) => Parser a -> (a -> Text) -> Maybe Text -> [Text] -> a -> SharedRep m a colorPicker :: Monad m => Maybe Text -> PixelRGB8 -> SharedRep m PixelRGB8 textbox :: Monad m => Maybe Text -> Text -> SharedRep m Text textarea :: Monad m => Int -> Maybe Text -> Text -> SharedRep m Text checkbox :: Monad m => Maybe Text -> Bool -> SharedRep m Bool toggle :: Monad m => Maybe Text -> Bool -> SharedRep m Bool button :: Monad m => Maybe Text -> SharedRep m Bool chooseFile :: Monad m => Maybe Text -> Text -> SharedRep m Text -- | represent a Maybe type using a checkbox hiding the underlying content -- on Nothing maybeRep :: Monad m => Maybe Text -> Bool -> SharedRep m a -> SharedRep m (Maybe a) -- | representation of web concerns (css, js & html) fiddle :: Monad m => Concerns Text -> SharedRep m (Concerns Text, Bool) -- | turns a SharedRep into a fiddle viaFiddle :: Monad m => SharedRep m a -> SharedRep m (Bool, Concerns Text, a) -- | a (fixed-size) list represented in html as an accordion card accordionList :: Monad m => Maybe Text -> Text -> Maybe Text -> (Text -> a -> SharedRep m a) -> [Text] -> [a] -> SharedRep m [a] -- | a fixed-sized list of Maybe a's listMaybeRep :: Monad m => Maybe Text -> Text -> (Text -> Maybe a -> SharedRep m (Maybe a)) -> Int -> [a] -> SharedRep m [Maybe a] -- | a SharedRep of [a]. Due to the applicative nature of the bridge, the -- size of lists has to be fixed on construction. listRep is a workaround -- for this, to enable some form of dynamic sizing. listRep :: Monad m => Maybe Text -> Text -> (Bool -> SharedRep m Bool) -> (a -> SharedRep m a) -> Int -> a -> [a] -> SharedRep m [a] defaultListLabels :: Int -> [Text] -- | haskell for web page representations module Web.Page -- | A JSON value represented as a Haskell value. data Value Object :: !Object -> Value Array :: !Array -> Value String :: !Text -> Value Number :: !Scientific -> Value Bool :: !Bool -> Value Null :: Value -- | A specialised variant of bracket with just a computation to run -- afterward. finally :: () => IO a -> IO b -> IO a -- | Classic pixel type storing 8bit red, green and blue (RGB) information. -- Values are stored in the following order: -- -- data PixelRGB8 PixelRGB8 :: {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> {-# UNPACK #-} !Pixel8 -> PixelRGB8 -- | A map from keys to values. A map cannot contain duplicate keys; each -- key can map to at most one value. data HashMap k v -- | The fromList function constructs the structure l from -- the given list of Item l fromList :: IsList l => [Item l] -> l -- | void value discards or ignores the result of -- evaluation, such as the return value of an IO action. -- --

Examples

-- -- Replace the contents of a Maybe Int with -- unit: -- --
--   >>> void Nothing
--   Nothing
--   
--   >>> void (Just 3)
--   Just ()
--   
-- -- Replace the contents of an Either Int -- Int with unit, resulting in an Either -- Int '()': -- --
--   >>> void (Left 8675309)
--   Left 8675309
--   
--   >>> void (Right 8675309)
--   Right ()
--   
-- -- Replace every element of a list with unit: -- --
--   >>> void [1,2,3]
--   [(),(),()]
--   
-- -- Replace the second element of a pair with unit: -- --
--   >>> void (1,2)
--   (1,())
--   
-- -- Discard the result of an IO action: -- --
--   >>> mapM print [1,2]
--   1
--   2
--   [(),()]
--   
--   >>> void $ mapM print [1,2]
--   1
--   2
--   
void :: Functor f => f a -> f () -- | Evaluate each action in the structure from left to right, and ignore -- the results. For a version that doesn't ignore the results see -- sequenceA. sequenceA_ :: (Foldable t, Applicative f) => t (f a) -> f () -- | A space efficient, packed, unboxed Unicode text type. data Text -- | O(n) Convert a String into a Text. Subject to -- fusion. Performs replacement on invalid scalar values. pack :: String -> Text -- | O(n) Convert a Text into a String. Subject to -- fusion. unpack :: Text -> String -- | Case analysis for the Bool type. bool x y p -- evaluates to x when p is False, and evaluates -- to y when p is True. -- -- This is equivalent to if p then y else x; that is, one can -- think of it as an if-then-else construct with its arguments reordered. -- --

Examples

-- -- Basic usage: -- --
--   >>> bool "foo" "bar" True
--   "bar"
--   
--   >>> bool "foo" "bar" False
--   "foo"
--   
-- -- Confirm that bool x y p and if p then y else -- x are equivalent: -- --
--   >>> let p = True; x = "bar"; y = "foo"
--   
--   >>> bool x y p == if p then y else x
--   True
--   
--   >>> let p = False
--   
--   >>> bool x y p == if p then y else x
--   True
--   
bool :: () => a -> a -> Bool -> a module Web.Page.Examples -- | simple page examples page1 :: Page page2 :: Page cfg2 :: PageConfig data RepExamples RepExamples :: Text -> Text -> Int -> Double -> Bool -> Bool -> Int -> Shape -> PixelRGB8 -> RepExamples [repTextbox] :: RepExamples -> Text [repTextarea] :: RepExamples -> Text [repSliderI] :: RepExamples -> Int [repSlider] :: RepExamples -> Double [repCheckbox] :: RepExamples -> Bool [repToggle] :: RepExamples -> Bool [repDropdown] :: RepExamples -> Int [repShape] :: RepExamples -> Shape [repColor] :: RepExamples -> PixelRGB8 repExamples :: Monad m => SharedRep m RepExamples data Shape SquareShape :: Shape CircleShape :: Shape fromShape :: Shape -> Text toShape :: Text -> Shape data SumTypeExample SumInt :: Int -> SumTypeExample SumOnly :: SumTypeExample SumText :: Text -> SumTypeExample repSumTypeExample :: Monad m => Int -> Text -> SumTypeExample -> SharedRep m SumTypeExample data SumType2Example SumOutside :: Int -> SumType2Example SumInside :: SumTypeExample -> SumType2Example repSumType2Example :: Monad m => Int -> Text -> SumTypeExample -> SumType2Example -> SharedRep m SumType2Example listExample :: Monad m => Int -> SharedRep m [Int] listRepExample :: Monad m => Int -> SharedRep m [Int] fiddleExample :: Concerns Text instance GHC.Generics.Generic Web.Page.Examples.SumType2Example instance GHC.Show.Show Web.Page.Examples.SumType2Example instance GHC.Classes.Eq Web.Page.Examples.SumType2Example instance GHC.Generics.Generic Web.Page.Examples.SumTypeExample instance GHC.Show.Show Web.Page.Examples.SumTypeExample instance GHC.Classes.Eq Web.Page.Examples.SumTypeExample instance GHC.Generics.Generic Web.Page.Examples.RepExamples instance GHC.Classes.Eq Web.Page.Examples.RepExamples instance GHC.Show.Show Web.Page.Examples.RepExamples instance GHC.Generics.Generic Web.Page.Examples.Shape instance GHC.Show.Show Web.Page.Examples.Shape instance GHC.Classes.Eq Web.Page.Examples.Shape