summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-01-09 03:24:03 +0000
committerGregor Kleen <gkleen@yggdrasil.li>2016-01-09 03:24:03 +0000
commit3989ea17b17b117b35808d3a5ea1279998a3cb29 (patch)
tree6c7f210eb37edfdd1b7f0215adbf1f84710fca03
parent318f1daf8b59b85ce45be0579109e02897768704 (diff)
downloaddirty-haskell.org-3989ea17b17b117b35808d3a5ea1279998a3cb29.tar
dirty-haskell.org-3989ea17b17b117b35808d3a5ea1279998a3cb29.tar.gz
dirty-haskell.org-3989ea17b17b117b35808d3a5ea1279998a3cb29.tar.bz2
dirty-haskell.org-3989ea17b17b117b35808d3a5ea1279998a3cb29.tar.xz
dirty-haskell.org-3989ea17b17b117b35808d3a5ea1279998a3cb29.zip
code excerpt from thermoprint rewrite
-rw-r--r--provider/posts/thermoprint-1.md48
1 files changed, 47 insertions, 1 deletions
diff --git a/provider/posts/thermoprint-1.md b/provider/posts/thermoprint-1.md
index bd98b71..642d739 100644
--- a/provider/posts/thermoprint-1.md
+++ b/provider/posts/thermoprint-1.md
@@ -41,7 +41,7 @@ the old one:
41 41
42## Features 42## Features
43 43
44Features I intend to implement include: 44git rFeatures I intend to implement include:
45 45
46 * A parser for a bbcode-dialect which should be used in both the cli tool and the 46 * A parser for a bbcode-dialect which should be used in both the cli tool and the
47 website (it will probably end up using 47 website (it will probably end up using
@@ -64,6 +64,8 @@ Features I intend to implement include:
64 64
65## Work so far 65## Work so far
66 66
67### Prototype
68
67I already have a prototype. 69I already have a prototype.
68It's quite bug-ridden and has recently developed serious problems actually 70It's quite bug-ridden and has recently developed serious problems actually
69printing after working satisfactorily for a few weeks. 71printing after working satisfactorily for a few weeks.
@@ -74,6 +76,50 @@ overall code quality.
74The [685 lines of code](http://cloc.sourceforge.net/) can be found in the 76The [685 lines of code](http://cloc.sourceforge.net/) can be found in the
75[repo](git://git.yggdrasil.li/thermoprint#master) as well. 77[repo](git://git.yggdrasil.li/thermoprint#master) as well.
76 78
79### Rewrite
80
81Currently the [rewrite](git://git.yggdrasil.li/thermoprint#rewrite) contains a
82single file of moment -- spec/src/Thermoprint/Printout.hs -- wherein we define
83the payload for the api -- our take on a structured document format (somewhat
84inspired by
85[pandoc](http://hackage.haskell.org/package/pandoc-types/docs/Text-Pandoc-Definition.html)):
86
87~~~ {.haskell}
88-- | A 'Printout' is a sequence of visually seperated 'Paragraph's
89type Printout = Seq Paragraph
90
91-- | A 'Paragraph' is a non-seperated sequence of 'Chunk's
92type Paragraph = Seq Chunk
93
94-- | We introduce both 'Chunk' and 'Paragraph' mainly to allow 'Raw'.
95--
96-- Were we to disallow 'Raw', 'Block' would be identical to 'Paragraph'
97data Chunk = Cooked Block -- ^ text semantically structured to be rendered in accordance with the display format of printer
98 | Raw ByteString -- ^ direct instructions to the printer
99 deriving (Generic, NFData, Show, CoArbitrary)
100
101-- | 'Block' is the entry point for our structured document format
102data Block = Line Line -- ^ a single 'Line' of text
103 | VSpace Integer -- ^ vertical space of height equivalent to 'Integer' lines
104 | NewlSep (Seq Block) -- ^ A sequence of 'Block's seperated by newlines
105 deriving (Generic, NFData, Show, CoArbitrary)
106
107{- | A 'Line' is one of:
108
109 * a single word
110 * horizontal space equivalent to the width of 'Integer' `em`.
111 * a sequence of words seperated by spaces
112
113We don't export all constructors and instead encourage the use of 'text'.
114-}
115data Line = Word Text
116 | HSpace Integer
117 | SpaceSep (Seq Line)
118 deriving (Generic, NFData, Show, CoArbitrary)
119~~~
120
121(The comments are verbatim as of 8307d7e).
122
77<!-- LocalWords: Thermoprint thermoprint json api cli yesod bbcode attoparsec 123<!-- LocalWords: Thermoprint thermoprint json api cli yesod bbcode attoparsec
78 --> 124 -->
79<!-- LocalWords: superset QuickCheck HUnit hspec datastructure repo 125<!-- LocalWords: superset QuickCheck HUnit hspec datastructure repo