svg-builder-0.1.1: DSL for building SVG.

Copyright | (c) 2015 Jeffrey Rosenbluth
License | BSD-style (see LICENSE)
Maintainer | jeffrey.rosenbluth@gmail.com
Safe Haskell | Safe-Inferred
Language | Haskell2010

Graphics.Svg.Core

Contents

- Types
- Combinators
- Rendering

Description

svg-builder Core types and functions.

Synopsis

- data Attribute
- data Element
- class ToElement a where
  - toElement :: a -> Element
- class Term result where
  - term :: Text -> [Attribute] -> result
- makeAttribute :: Text -> Text -> Attribute
- makeElement :: Text -> Element -> Element
- makeElementNoEnd :: Text -> Element
- makeElementDoctype :: Text -> Element
- with :: Element -> [Attribute] -> Element
- renderBS :: Element -> ByteString
- renderToFile :: FilePath -> Element -> IO ()
- renderText :: Element -> Text

# Types

data Attribute Source #

Attribute name value.

#### Instances

Instances details

Show Attribute Source # |
Instance details Defined in Graphics.Svg.Core Methods showsPrec :: Int -> Attribute -> ShowS Source # show :: Attribute -> String Source # showList :: [Attribute] -> ShowS Source #
Eq Attribute Source # |
Instance details Defined in Graphics.Svg.Core Methods (==) :: Attribute -> Attribute -> Bool Source # (/=) :: Attribute -> Attribute -> Bool Source #
Hashable Attribute Source # |
Instance details Defined in Graphics.Svg.Core Methods hashWithSalt :: Int -> Attribute -> Int Source # hash :: Attribute -> Int Source #

data Element Source #

Type of an SVG element.

#### Instances

Instances details

IsString Element Source # |
Instance details Defined in Graphics.Svg.Core Methods fromString :: String -> Element Source #
Monoid Element Source # |
Instance details Defined in Graphics.Svg.Core Methods mempty :: Element Source # mappend :: Element -> Element -> Element Source # mconcat :: [Element] -> Element Source #
Semigroup Element Source # |
Instance details Defined in Graphics.Svg.Core Methods (<>) :: Element -> Element -> Element Source # sconcat :: NonEmpty Element -> Element Source # stimes :: Integral b => b -> Element -> Element Source #
Show Element Source # |
Instance details Defined in Graphics.Svg.Core Methods showsPrec :: Int -> Element -> ShowS Source # show :: Element -> String Source # showList :: [Element] -> ShowS Source #
Term Element Source # |
Instance details Defined in Graphics.Svg.Core Methods term :: Text -> [Attribute] -> Element Source #
e ~ Element => Term (e -> Element) Source # |
Instance details Defined in Graphics.Svg.Core Methods term :: Text -> [Attribute] -> e -> Element Source #

class ToElement a where Source #

Things that can be converted to SVG elements.

Methods

toElement :: a -> Element Source #

#### Instances

Instances details

ToElement Text Source # |
Instance details Defined in Graphics.Svg.Core Methods toElement :: Text -> Element Source #
ToElement Text Source # |
Instance details Defined in Graphics.Svg.Core Methods toElement :: Text -> Element Source #
ToElement String Source # |
Instance details Defined in Graphics.Svg.Core Methods toElement :: String -> Element Source #

class Term result where Source #

Used to make specific SVG element builders.

Methods

term :: Text -> [Attribute] -> result Source #

Used for constructing elements e.g. `term "circle"` yields `circle_`.

#### Instances

Instances details

Term Element Source # |
Instance details Defined in Graphics.Svg.Core Methods term :: Text -> [Attribute] -> Element Source #
e ~ Element => Term (e -> Element) Source # |
Instance details Defined in Graphics.Svg.Core Methods term :: Text -> [Attribute] -> e -> Element Source #

# Combinators

makeAttribute Source #

Arguments

:: Text | Attribute name.
-> Text | Attribute value.
-> Attribute |

Make an attribute.

makeElement :: Text -> Element -> Element Source #

Make an SVG element builder

makeElementNoEnd :: Text -> Element Source #

Make an SVG element with no end tag, contains only attributes.

makeElementDoctype :: Text -> Element Source #

Make an SVG doctype element builder.

with :: Element -> [Attribute] -> Element Source #

Add a list of attributes to an element

# Rendering

renderBS :: Element -> ByteString Source #

Render a `Element` to lazy bytestring.

renderToFile :: FilePath -> Element -> IO () Source #

Render a `Element` to a file.

renderText :: Element -> Text Source #

Reder an `Element` to lazy text.