type-of-html-static 0.1.0.1 → 0.1.0.2
raw patch · 3 files changed
+10/−8 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Readme.md +7/−5
- src/Html/Static.hs +2/−2
- type-of-html-static.cabal +1/−1
Readme.md view
@@ -1,14 +1,16 @@ # Type of html static -This little companion library of `Type of html` provides just two-little function: `static :: Document a => a -> Q Exp`. Using this-template haskell function on any part of your html document will-escape, render and lift to a Symbol at compile time.+This little companion library of+[https://hackage.haskell.org/package/type-of-html](Type of html)+provides just two little functions:+`static :: Document a => a -> Q Exp`.+Using this template haskell function on any part of your html+document will escape, render and lift to a Symbol at compile time. It increases performance a lot by avoiding any runtime computation. By producing Proxy Symbol, it will fuse at compiletime with adjacent elements in your document. -`optimize :: Q Exp -> Q Exp` takes an quoted definition of a html+`optimize :: Q Exp -> Q Exp` takes a quoted definition of a html document and tries to convert all literals to compile time escaped Proxy Symbol. It is less powerfull than `static` but more convenient.
src/Html/Static.hs view
@@ -27,7 +27,7 @@ -- | Try to optimize a quoted html document at compiletime. -- -- >>> :t \x -> $(optimize [| div_ "a" # x |])--- \x -> Proxy "<div>a</div>" # x+-- \x -> 'Div > Proxy "a" # x -- -- This function recurses into an Q Exp and turns every literal -- expression which is applied to an element or to an attribute into a@@ -53,7 +53,7 @@ optimize = fmap f where- f (AppE (VarE a) b) | nameModule a == Just "Html.Element" = AppE (VarE a) (f b)+ f (AppE (VarE a) b) | nameModule a == Just "Html.Element" || nameModule a == Just "Html.Attribute" = AppE (VarE a) (f b) f (AppE (AppE (VarE a) b) c) | nameModule a == Just "Html.Element" || nameModule a == Just "Html.Type.Internal" && nameBase a == "#" = AppE (AppE (VarE a) (f b)) (f c) f (InfixE (Just a) (VarE b) (Just c)) | nameModule b == Just "Html.Type.Internal" && nameBase b == "#" = InfixE (Just (f a)) (VarE b) (Just (f c))
type-of-html-static.cabal view
@@ -1,5 +1,5 @@ name: type-of-html-static-version: 0.1.0.1+version: 0.1.0.2 synopsis: Optimize static parts of type-of-html. description: This library provides the TH-function 'static' to annote which parts of your page are static to dramatically increase performance. It converts and escapes it's argument at compiletime and lifts it to a Proxy Symbol to avoid even appending of Builder.