@@ -6,7 +6,7 @@
66
77-- | This module contains Shakespearean (see "Text.Shakespeare") templates for Elm.
88-- It introduces type-safe compile-time variable and URL interpolation. A typeclass
9−-- 'ToElm' is provided for interpolated variables.
9+-- @'ToElm'@ is provided for interpolated variables.
1010--
1111-- Further reading on Shakespearean templates: <http://www.yesodweb.com/book/templates>
1212--
@@ -14,8 +14,11 @@
1414module Language.Elm.Quasi
1515 ( -- * Functions
1616 -- ** Template-Reading Functions
17− -- | These QuasiQuoter and Template Haskell methods return values of
18− -- type @'ElmUrl' url@. See the Yesod book for details.
17+ -- |These QuasiQuoters return functions of the type @(t -> 'Elm')@
18+ -- where @t@ is the URL rendering function if type-safe URLs are used.
19+ --
20+ -- A usage example for both type-safe (Yesod) and standard path segment (Happstack)
21+ -- URLs is provided in the Examples folder in the Git repository.
1922 elm
2023 , elmFile
2124 , elmFileReload
@@ -39,7 +42,7 @@ import qualified Data.Text as TS
3942import qualified Data.Text.Lazy as TL
4043import Text.Shakespeare
4144
42−-- | Render Elm to lazy Text without route interpolation.
45+-- | Render Elm to lazy Text.
4346renderElm :: Elm -> TL.Text
4447renderElm (Elm b) = toLazyText b
4548
@@ -47,7 +50,7 @@ renderElm (Elm b) = toLazyText b
4750newtype Elm = Elm { unElm :: Builder }
4851 deriving Monoid
4952
50−-- | A typeclass for types that can be interpolated in CoffeeScript templates.
53+-- | A typeclass for types that can be interpolated in Elm templates.
5154class ToElm a where
5255 toElm :: a -> Builder
5356instance ToElm [Char] where toElm = fromLazyText . TL.pack
@@ -64,12 +67,21 @@ elmSettings = do
6467 , unwrap = unWrapExp
6568 }
6669
70+-- |QuasiQuoter for embedding Elm code inside of Haskell code.
71+--
72+-- Usage:
73+-- @[elm|main = plaintext "Some elm code"|]@
6774elm :: QuasiQuoter
6875elm = QuasiQuoter { quoteExp = \s -> do
6976 rs <- elmSettings
7077 quoteExp (shakespeare rs) s
7178 }
7279
80+-- |A Template Haskell function for embedding Elm code from external
81+-- .elm files.
82+--
83+-- Usage:
84+-- @$(elmFile "elm_source/index.elm")@
7385elmFile :: FilePath -> Q Exp
7486elmFile fp = do
7587 rs <- elmSettings