type-of-html 1.3.2.0 → 1.3.2.1
raw patch · 3 files changed
+29/−13 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- bench/Small.hs +18/−7
- src/Html.hs +10/−5
- type-of-html.cabal +1/−1
bench/Small.hs view
@@ -11,6 +11,7 @@ import qualified Data.Text as T import qualified Data.Text.Lazy as LT import Data.IORef+import System.IO.Unsafe import Criterion.Main import Control.Arrow@@ -46,23 +47,33 @@ , bench "elementWithAttribute" $ nf (\x -> renderByteString $ div_A (A.class_ x) x) "" , bench "elementWithParallelAttribute" $ nf (\x -> renderByteString $ div_A (A.class_ x # A.id_ x) x) "" , bench "listOfAttributes" $ nf (\x -> renderByteString [A.class_ x, A.class_ x]) ""- , bench "Runtime String" $ nfIO (renderByteString <$> runtimeTxt)+ , bench "Runtime String" $ nfIO (renderByteString <$> readIORef runtimeString) , bench "String" $ nf renderByteString "abcdefghijklmnopqrstuvwxyz<>&;"- , bench "Runtime Raw String" $ nfIO (renderByteString . Raw <$> runtimeTxt)+ , bench "Runtime Raw String" $ nfIO (renderByteString . Raw <$> readIORef runtimeString) , bench "Raw String" $ nf renderByteString (Raw "abcdefghijklmnopqrstuvwxyz<>&;")- , bench "Runtime strict Text" $ nfIO (renderByteString . T.pack <$> runtimeTxt)+ , bench "Runtime strict Text" $ nfIO (renderByteString <$> readIORef runtimeStrictText) , bench "strict Text" $ nf renderByteString (T.pack "abcdefghijklmnopqrstuvwxyz<>&;")- , bench "Runtime Raw strict Text" $ nfIO (renderByteString . Raw . T.pack <$> runtimeTxt)+ , bench "Runtime Raw strict Text" $ nfIO (renderByteString . Raw <$> readIORef runtimeStrictText) , bench "Raw strict Text" $ nf renderByteString (Raw (T.pack "abcdefghijklmnopqrstuvwxyz<>&;"))- , bench "Runtime lazy Text" $ nfIO (renderByteString . LT.pack <$> runtimeTxt)+ , bench "Runtime lazy Text" $ nfIO (renderByteString <$> readIORef runtimeLazyText) , bench "lazy Text" $ nf renderByteString (LT.pack "abcdefghijklmnopqrstuvwxyz<>&;")- , bench "Runtime Raw lazy Text" $ nfIO (renderByteString . Raw . LT.pack <$> runtimeTxt)+ , bench "Runtime Raw lazy Text" $ nfIO (renderByteString . Raw <$> readIORef runtimeLazyText) , bench "Raw lazy Text" $ nf renderByteString (Raw (LT.pack "abcdefghijklmnopqrstuvwxyz<>&;")) , bench "listOfListOf" $ nf (\x -> renderByteString $ div_ [i_ [span_ x]]) "" ] where -runtimeTxt = newIORef "abcdefghijklmnopqrstuvwxyz<>&;" >>= readIORef+{-# NOINLINE runtimeString #-}+runtimeString :: IORef String+runtimeString = unsafePerformIO $ newIORef "abcdefghijklmnopqrstuvwxyz<>&;"++{-# NOINLINE runtimeLazyText #-}+runtimeLazyText :: IORef LT.Text+runtimeLazyText = unsafePerformIO . newIORef $ LT.pack "abcdefghijklmnopqrstuvwxyz<>&;"++{-# NOINLINE runtimeStrictText #-}+runtimeStrictText :: IORef T.Text+runtimeStrictText = unsafePerformIO . newIORef $ T.pack "abcdefghijklmnopqrstuvwxyz<>&;" oneElement, oneElement', oneElement'' :: ('Div ?> a)
src/Html.hs view
@@ -23,10 +23,11 @@ import Html.Type import Html.Type.Internal -import qualified Data.ByteString.Lazy as B-import qualified Data.ByteString.Builder as B-import qualified Data.Text.Lazy as T-import qualified Data.Text.Lazy.Encoding as T+import qualified Data.ByteString.Lazy as B+import qualified Data.ByteString.Builder as B+import qualified Data.ByteString.Builder.Extra as BE+import qualified Data.Text.Lazy as T+import qualified Data.Text.Lazy.Encoding as T -- | Constraint synonym of html documents. type Document a = Document' a@@ -50,7 +51,11 @@ -- | Render a html document to a lazy ByteString. {-# INLINE renderByteString #-} renderByteString :: Document a => a -> B.ByteString-renderByteString = B.toLazyByteString . renderBuilder+renderByteString = BE.toLazyByteStringWith+ ( BE.untrimmedStrategy+ BE.smallChunkSize+ BE.defaultChunkSize+ ) B.empty . renderBuilder -- | Orphan show instance to faciliate ghci development. instance {-# OVERLAPPABLE #-} Document a => Show a where show = renderString
type-of-html.cabal view
@@ -1,5 +1,5 @@ name: type-of-html-version: 1.3.2.0+version: 1.3.2.1 synopsis: High performance type driven html generation. description: This library makes most invalid html documents compile time errors and uses advanced type level features to realise compile time computations. license: BSD3