aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJohannes Gerer <oss@johannesgerer.com>2016-10-27 14:00:05 +0200
committerJohannes Gerer <oss@johannesgerer.com>2016-10-27 14:00:05 +0200
commitbd93b7c0b050dc23b652f918ed3a98ea6b386962 (patch)
tree25a8ea123764e39b8402091dddec96e575de43b6
parentcdfc5a078a334f8467fb52f30c3ef544b63be4d0 (diff)
downloadblazeT-bd93b7c0b050dc23b652f918ed3a98ea6b386962.tar.gz
blazeT-bd93b7c0b050dc23b652f918ed3a98ea6b386962.tar.zst
blazeT-bd93b7c0b050dc23b652f918ed3a98ea6b386962.zip
Docsv0.0.4
-rw-r--r--README.md48
-rw-r--r--blazeT.cabal2
-rw-r--r--src/Text/BlazeT/Internal.hs2
3 files changed, 30 insertions, 22 deletions
diff --git a/README.md b/README.md
index 37e4be5..ed1bf0e 100644
--- a/README.md
+++ b/README.md
@@ -3,30 +3,38 @@
3A true monad (transformer) version of the 3A true monad (transformer) version of the
4[blaze-markup](https://hackage.haskell.org/package/blaze-markup) and 4[blaze-markup](https://hackage.haskell.org/package/blaze-markup) and
5[blaze-html](https://hackage.haskell.org/package/blaze-html) 5[blaze-html](https://hackage.haskell.org/package/blaze-html)
6libraries. 6libraries:
7 7
8# Why? 8> BlazeHtml is a blazingly fast HTML combinator library for the
9> Haskell programming language. It embeds HTML templates in Haskell
10> code for optimal efficiency and composability.
11
12— from https://jaspervdj.be/blaze/.
13
14## What’s wrong with blaze?
15
16Blaze’s `Markup` and `Html` **cannot be used as Monads**, let alone Monad transformers.
9 17
10While blaze's `Markup` and `Html` types have `Monad` instances and can 18While blaze's `Markup` and `Html` types have `Monad` instances and can
11leverage the the concise `do` notation, they do not satisfy 19leverage the concise `do` notation, they do not satisfy the
12the 20[Monad Laws](https://hackage.haskell.org/package/base-4.8.0.0/docs/Control-Monad.html#t:Monad).
13[Monad Laws](https://hackage.haskell.org/package/base-4.8.0.0/docs/Control-Monad.html#t:Monad) and
14thus cannot be used as Monads, let alone Monad transformers.
15 21
16## Use Cases 22## How do Monads help? - Use Cases
17 23
18The `MarkupT` Monad Transformer enables us to write Markup (e.g. HTML) 24The `MarkupT` Monad Transformer enables us to write Markup (e.g. HTML)
19templates that have access to all those Monads you cannot live without 25templates that have access to all those Monads you cannot live without
20anymore. 26anymore.
21 27
22Accessing an environment 28The first things that come to mind:
23([MonadReader](https://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Reader-Class.html)), 29
24accumulating log or other diagnostic output 30* Accessing an environment
31([MonadReader](https://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Reader-Class.html))
32* Logging and other diagnostic output
25([MonadWriter](https://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Writer-Class.html)), 33([MonadWriter](https://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Writer-Class.html)),
26doing `IO` (like database access) are the first things that come to 34* `IO` (e.g. for database access)
27mind. 35
28 36
29The reason of existence of this library is its use 37The reason for the existence of this library is its use
30in [Lykah](http://johannesgerer.com/Lykah), which powers my personal 38in [Lykah](http://johannesgerer.com/Lykah), which powers my personal
31website 39website
32[http://johannesgerer.com](http://johannesgerer.com/johannesgerer.com). In 40[http://johannesgerer.com](http://johannesgerer.com/johannesgerer.com). In
@@ -35,9 +43,9 @@ build things like menus or blog post lists) and automatically check,
35insert and keep track of referenced pages and assets, which turns out 43insert and keep track of referenced pages and assets, which turns out
36to be very useful functionality of a static website generator. 44to be very useful functionality of a static website generator.
37 45
38# How to use it? 46## Usage
39 47
40## Backwards compatible 48### Integrating with your existing code
41 49
42The library is intended to serve as a drop-in replacement for the 50The library is intended to serve as a drop-in replacement for the
43`blaze-markup` and `blaze-html` libraries and should be backwards 51`blaze-markup` and `blaze-html` libraries and should be backwards
@@ -49,7 +57,7 @@ Text.BlazeT.*` and it should give the same results.
49For usage of blaze check out 57For usage of blaze check out
50their [documentation](https://jaspervdj.be/blaze/). 58their [documentation](https://jaspervdj.be/blaze/).
51 59
52## Unleash the monads 60### Unleash the monads
53 61
54[Text.BlazeT](https://hackage.haskell.org/package/blazeT/docs/Text-BlazeT.html) 62[Text.BlazeT](https://hackage.haskell.org/package/blazeT/docs/Text-BlazeT.html)
55exports `runWith` and `execWith`, which work on any 63exports `runWith` and `execWith`, which work on any
@@ -92,7 +100,7 @@ prints:
92<p>created with blazeT at 2016-10-26 01:09:16.969147361 UTC</p> 100<p>created with blazeT at 2016-10-26 01:09:16.969147361 UTC</p>
93``` 101```
94 102
95# Installation 103## Installation
96 104
971. To make it available on your system (or sandbox) use `cabal install blazeT`. 1051. To make it available on your system (or sandbox) use `cabal install blazeT`.
98 106
@@ -104,9 +112,9 @@ cabal sandbox init #optional
104cabal install 112cabal install
105``` 113```
106 114
107# Documentation on [Hackage](https://hackage.haskell.org/package/blazeT) 115## Documentation on [Hackage](https://hackage.haskell.org/package/blazeT)
108 116
109# Implementation 117## Implementation
110 118
111... is contained 119... is contained
112in 120in
@@ -116,7 +124,7 @@ Everything is build around the simple `newtype` definition of the
116`MarkupT` transformer, which makes use 124`MarkupT` transformer, which makes use
117the 125the
118[Monoid](https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Monoid.html) instance 126[Monoid](https://hackage.haskell.org/package/base-4.7.0.2/docs/Data-Monoid.html) instance
119of `Blaze.Markup` and is basically a `WriterT` writing `Blaze.Markup`: 127of `Blaze.Markup` and is simply a `WriterT` writing `Blaze.Markup`:
120 128
121```Haskell 129```Haskell
122newtype MarkupT m a = MarkupT { fromMarkupT :: WriterT B.Markup m a } 130newtype MarkupT m a = MarkupT { fromMarkupT :: WriterT B.Markup m a }
diff --git a/blazeT.cabal b/blazeT.cabal
index 42e44ba..8bfd200 100644
--- a/blazeT.cabal
+++ b/blazeT.cabal
@@ -1,5 +1,5 @@
1Name: blazeT 1Name: blazeT
2Version: 0.0.2 2Version: 0.0.4
3Homepage: 3Homepage:
4Bug-Reports: http://github.com/johannesgerer/blazeT/issues 4Bug-Reports: http://github.com/johannesgerer/blazeT/issues
5License: MIT 5License: MIT
diff --git a/src/Text/BlazeT/Internal.hs b/src/Text/BlazeT/Internal.hs
index 1a2fe8c..fcdf944 100644
--- a/src/Text/BlazeT/Internal.hs
+++ b/src/Text/BlazeT/Internal.hs
@@ -114,7 +114,7 @@ import qualified Text.Blaze.Internal as Text.Blaze
114 114
115{- | Everything is build around the simple @newtype@ definition of the 115{- | Everything is build around the simple @newtype@ definition of the
116'MarkupT' transformer, which makes use the 'Monoid' instance of Blaze 116'MarkupT' transformer, which makes use the 'Monoid' instance of Blaze
117'Text.Blaze.Markup' and is basically a 'WriterT' writing Blaze 117'Text.Blaze.Markup' and is simply a 'WriterT' writing Blaze
118'Text.Blaze.Markup': 118'Text.Blaze.Markup':
119-} 119-}
120newtype MarkupT m a= MarkupT { fromMarkupT :: WriterT Text.Blaze.Markup m a } 120newtype MarkupT m a= MarkupT { fromMarkupT :: WriterT Text.Blaze.Markup m a }