-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | lightweight CSS DSL
--   
--   a tiny css preprocessor dsl for haskell – check out the readme at
--   <a>https://github.com/intolerable/stitch</a>
@package stitch
@version 0.5.0.0


-- | This module defines everything used to manage CSS selectors: creating
--   them as well as combining them (using the <a>Monoid</a> instance). It
--   also includes a function <a>fromText</a> for converting arbitrary
--   <a>Text</a>s to <a>Selector</a>s.
module Stitch.Types.Selector

-- | Represents a CSS selector. Can be combined with other <a>Selector</a>s
--   using its <a>Monoid</a> instance.
newtype Selector
Selector :: [Text] -> Selector
[unSelector] :: Selector -> [Text]

-- | Parse a <a>Selector</a> from a <a>Text</a> value. This is the same
--   function used by the <a>IsString</a> instance used by
--   <tt>OverloadedStrings</tt>.
fromText :: Text -> Selector
instance GHC.Classes.Ord Stitch.Types.Selector.Selector
instance GHC.Classes.Eq Stitch.Types.Selector.Selector
instance GHC.Read.Read Stitch.Types.Selector.Selector
instance GHC.Show.Show Stitch.Types.Selector.Selector
instance Data.String.IsString Stitch.Types.Selector.Selector
instance GHC.Base.Monoid Stitch.Types.Selector.Selector


-- | Defines all the types needed for <a>Stitch</a>'s internal CSS
--   representation. You shouldn't need to import this module unless you're
--   messing around with the <a>Block</a> representation before outputting
--   CSS.
module Stitch.Types

-- | Represents a CSS selector. Can be combined with other <a>Selector</a>s
--   using its <a>Monoid</a> instance.
newtype Selector
Selector :: [Text] -> Selector
[unSelector] :: Selector -> [Text]

-- | Children is a simple specialized wrapper around <a>Map</a> with a
--   custom <a>Monoid</a> instance. Instead of simply <a>union</a>ing the
--   two <a>Map</a>s, the <a>Children</a> instance <a>mappend</a>s the two
--   values together in case of a key clash.
newtype Children
Children :: (Map Selector InnerBlock) -> Children

-- | Type for a CSS property or comment. The two are combined because we
--   want to keep the ordering of comments and properties in the output
--   CSS.
data Property
Property :: Text -> Text -> Property
Comment :: Text -> Property

-- | Basic newtype for handling css @<tt>import</tt> statements.
newtype Import
Import :: Text -> Import

-- | Top-level representation of a CSS document.
data Block
Block :: [Import] -> [Property] -> Children -> Block

-- | Representation of a CSS inner block. Similar to a top-level
--   <a>Block</a>, but doesn't allow <a>Import</a>s.
data InnerBlock
InnerBlock :: [Property] -> Children -> InnerBlock
instance GHC.Classes.Eq Stitch.Types.Block
instance GHC.Read.Read Stitch.Types.Block
instance GHC.Show.Show Stitch.Types.Block
instance GHC.Classes.Eq Stitch.Types.Children
instance GHC.Read.Read Stitch.Types.Children
instance GHC.Show.Show Stitch.Types.Children
instance GHC.Classes.Eq Stitch.Types.InnerBlock
instance GHC.Read.Read Stitch.Types.InnerBlock
instance GHC.Show.Show Stitch.Types.InnerBlock
instance GHC.Classes.Eq Stitch.Types.Import
instance GHC.Read.Read Stitch.Types.Import
instance GHC.Show.Show Stitch.Types.Import
instance GHC.Classes.Eq Stitch.Types.Property
instance GHC.Read.Read Stitch.Types.Property
instance GHC.Show.Show Stitch.Types.Property
instance GHC.Base.Monoid Stitch.Types.Block
instance GHC.Base.Monoid Stitch.Types.Children
instance GHC.Base.Monoid Stitch.Types.InnerBlock

module Control.Monad.Trans.Stitch
newtype StitchT m a
StitchT :: (WriterT Block m a) -> StitchT m a
runStitchT :: Monad m => StitchT m a -> m (a, Block)
instance Control.Monad.Trans.Class.MonadTrans Control.Monad.Trans.Stitch.StitchT
instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Trans.Stitch.StitchT m)
instance GHC.Base.Alternative m => GHC.Base.Alternative (Control.Monad.Trans.Stitch.StitchT m)
instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Trans.Stitch.StitchT m)
instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Monad.Trans.Stitch.StitchT m)
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Trans.Stitch.StitchT m)
instance (GHC.Base.Applicative m, GHC.Base.Monoid a) => GHC.Base.Monoid (Control.Monad.Trans.Stitch.StitchT m a)


-- | This module defines most of the functions that are core to the DSL.
--   Most of them are re-exported by <a>Stitch</a>, so you usually
--   shouldn't need to import this module directly (unless you want to use
--   CSS imports).
module Stitch.Combinators

-- | Add a key-value property pair. For example, <tt>"color" .= "red"</tt>
--   will add <tt>color: red</tt> to the CSS output.
(.=) :: Monad m => Text -> Text -> StitchT m ()
infix 8 .=

-- | Nest a selector under the current selector. For example, this:
--   
--   <pre>
--   "h1" ? do
--     "color" .= "red"
--     "a" ?
--       "text-decoration" .= "underline"
--   </pre>
--   
--   | results in the following being added to the CSS output:
--   
--   <pre>
--   h1 {
--     color: red
--   }
--   h1 a {
--     text-decoration: underline
--   }
--   </pre>
(?) :: Monad m => Selector -> StitchT m a -> StitchT m a
infixr 6 ?

-- | <tt>"pref" -: assignments</tt> prefixes all the keys of
--   <tt>assignments</tt> with <tt>pref-</tt>. This can be useful for
--   putting a bunch of grouped "font" or "border" properties together –
--   for example, the following two actions function the same:
--   
--   <pre>
--   "font" -: do
--     "size" .= "1.5rem"
--     "family" .= "Helvetica"
--     "weight" .= "bold"
--   </pre>
--   
--   <pre>
--   "font-size" .= "1.5rem"
--   "font-family" .= "Helvetica"
--   "font-weight" .= "bold"
--   </pre>
(-:) :: Monad m => Text -> StitchT m a -> StitchT m a
infixr 6 -:

-- | Add a comment to the CSS output. The <a>compressed</a> printer won't
--   add comments to the final CSS output.
comment :: Monad m => Text -> StitchT m ()

-- | Add an <tt>@import</tt> statement to the top-level of the CSS output.
cssImport :: Monad m => Text -> StitchT m ()


-- | This module exports the <a>Stitch</a> type, which is simply
--   <a>StitchT</a> parameterized over <a>Identity</a>, for computations
--   which don't require any other monadic capabilities.
module Control.Monad.Stitch

-- | The <a>StitchT</a> monad transformer specialized to <a>Identity</a>.
--   This will typically be the Stitch variant used since it doesn't do
--   anything special.
type Stitch = StitchT Identity

-- | Abstract representation of a CSS document. This can be transformed to
--   an actual CSS document with <a>renderCSS</a>.
type CSS = Stitch ()

-- | Evaluate a computation in the <a>Stitch</a> monad, returning
--   computation's value and a concrete representation of the CSS document.
runStitch :: Stitch a -> (a, Block)


-- | This module contains all the functions needed to convert a CSS
--   document from its internal representation (<a>Block</a>) to a concrete
--   text-format CSS output.
module Stitch.Render

-- | Convert an abstract <a>CSS</a> document to a real CSS document.
renderCSS :: CSS -> Text
printCSS :: CSS -> IO ()

-- | Type of the CSS printers – a function from the internal <a>Block</a>
--   representation of the CSS to a concrete <a>Text</a> output.
type BlockPrinter = (Block -> Text)

-- | Convert an abstract <a>CSS</a> document to a real CSS document using a
--   specific printer. A simple printer called <a>basic</a> is included, as
--   well as a compressing printer called <a>compressed</a>.
renderCSSWith :: BlockPrinter -> CSS -> Text

-- | Convert an abstract <a>CSS</a> document built with the <a>StitchT</a>
--   transformer into its monad-wrapped <a>Text</a> output. Unless you're
--   explicitly using the transformer, this function is probably not
--   useful.
renderStitchTWith :: Monad m => BlockPrinter -> StitchT m () -> m Text

-- | Outputs a basic human-readable version of the CSS document. Line
--   breaks are added between blocks, and properties are spaced nicely.
basic :: BlockPrinter

-- | A minimal printer that aims for tiny output CSS. All spaces are
--   removed.
compressed :: BlockPrinter


-- | Importing this module should bring enough functions into scope to use
--   the Stitch DSL for most purposes.
module Stitch

-- | Abstract representation of a CSS document. This can be transformed to
--   an actual CSS document with <a>renderCSS</a>.
type CSS = Stitch ()

-- | Convert an abstract <a>CSS</a> document to a real CSS document.
renderCSS :: CSS -> Text
printCSS :: CSS -> IO ()

-- | Represents a CSS selector. Can be combined with other <a>Selector</a>s
--   using its <a>Monoid</a> instance.
newtype Selector
Selector :: [Text] -> Selector
[unSelector] :: Selector -> [Text]

-- | Nest a selector under the current selector. For example, this:
--   
--   <pre>
--   "h1" ? do
--     "color" .= "red"
--     "a" ?
--       "text-decoration" .= "underline"
--   </pre>
--   
--   | results in the following being added to the CSS output:
--   
--   <pre>
--   h1 {
--     color: red
--   }
--   h1 a {
--     text-decoration: underline
--   }
--   </pre>
(?) :: Monad m => Selector -> StitchT m a -> StitchT m a
infixr 6 ?

-- | Add a key-value property pair. For example, <tt>"color" .= "red"</tt>
--   will add <tt>color: red</tt> to the CSS output.
(.=) :: Monad m => Text -> Text -> StitchT m ()
infix 8 .=

-- | Add a comment to the CSS output. The <a>compressed</a> printer won't
--   add comments to the final CSS output.
comment :: Monad m => Text -> StitchT m ()


-- | An example of how to use <a>Stitch</a>.
module Stitch.Example

-- | An example of a CSS document defined programmatically using
--   <a>Stitch</a>. To convert this to an real CSS document, use
--   <a>renderCSS</a>.
exampleCSS :: CSS

-- | An example of <a>Stitch</a>'s output. Uses the <a>basic</a> printer.
exampleOutput :: Text
