summaryrefslogtreecommitdiff
path: root/ws2015/ffp/anmeldung/anmeldung.md
diff options
context:
space:
mode:
Diffstat (limited to 'ws2015/ffp/anmeldung/anmeldung.md')
-rw-r--r--ws2015/ffp/anmeldung/anmeldung.md121
1 files changed, 121 insertions, 0 deletions
diff --git a/ws2015/ffp/anmeldung/anmeldung.md b/ws2015/ffp/anmeldung/anmeldung.md
new file mode 100644
index 0000000..3e0ce17
--- /dev/null
+++ b/ws2015/ffp/anmeldung/anmeldung.md
@@ -0,0 +1,121 @@
1---
2title: A toolset for interacting with character-oriented printers
3author:
4 - "[Gregor Kleen](mailto:gkleen@math.lmu.de)"
5date: 2016-01-14
6tags: Thermoprint
7header-includes:
8 - \usepackage{hyperref}
9 - \hypersetup{colorlinks=true}
10 - \usepackage{enumitem}
11 - \setlist[description]{style=nextline}
12---
13
14This file is an updated version of the [original blog-post](https://dirty-haskell.org/posts/thermoprint-1.html).
15
16# Project description
17
18## Motivation
19
20Some time ago I bought a cheap Chinese
21[thermoprinter](https://en.wikipedia.org/wiki/Thermal_printing) off eBay.
22As expected the printers firmware is really awkward to use (including binary
23control codes used to switch between char sets such as bold, italic, underlined,
24etc.).
25The obvious solution was to write a library to parse a more sensible
26representation and send it to be printed.
27
28Since there might, at some point, be other users wanting to print to my
29acquisition the architecture is intended to present a somewhat usable
30interface to the uninitiated.
31
32## Implementation
33
34### Location
35
36Recently I created a new branch in
37[thermoprint](http://git.yggdrasil.li/thermoprint) called
38[rewrite](http://git.yggdrasil.li/thermoprint?h=rewrite).
39
40### Architecture Overview
41
42The new macroscopic architecture I´m currently aiming for is quite similar to
43the old one:
44
45 * A server intended to run on the machine connected to my cheap printer talking
46 directly to the printer on one end and serving a
47 [json api](https://hackage.haskell.org/package/servant) on the other.
48 * A (hopefully) tiny cli tool for debugging and personal use.
49 * A website (it will probably end up being based on
50 [threepenny](https://hackage.haskell.org/package/threepenny-gui)) presenting a web interface
51 similar to the cli tool.
52
53### Features
54
55Features I intend to implement include:
56
57 * A parser for a bbcode-dialect which should be used in both the cli tool and the
58 website (it will probably end up using
59 [attoparsec](https://hackage.haskell.org/package/attoparsec)) -- bbcode as
60 presented on [Wikipedia](https://en.wikipedia.org/wiki/BBCode) is a proper
61 superset of the feature-set of my cheap Chinese printer.
62 * Reasonable test coverage using
63 [QuickCheck](https://hackage.haskell.org/package/QuickCheck),
64 [HUnit](http://hackage.haskell.org/package/HUnit).
65
66 Automatic testing with [cabal](https://www.haskell.org/cabal/) facilitated by
67 [hspec](https://hackage.haskell.org/package/hspec).
68 * Support and server-side storage for drafts.
69 * The Website should provide some richer formats than bbcode which will
70 probably find inclusion in the payload datastructure such as lists,
71 checklists, tables, etc.
72
73 The cli-tool should be able to use these too (the input will probably end up
74 being json-formatted).
75
76### Connection to the lecture
77
78We inted to implement:
79
80* A parser using [attoparsec](https://hackage.haskell.org/package/attoparsec))
81* A graphical user interface/website using [threepenny](https://hackage.haskell.org/package/threepenny-gui)
82* A CLI-tool using [optparse-applicative](https://hackage.haskell.org/package/optparse-applicative)
83* A [servant](https://hackage.haskell.org/package/servant) based API
84* Some parallelism using [stm](https://hackage.haskell.org/package/stm) for management of printer-queues and the like within the API-backend
85
86Of which only the use of stm was discussed in the lecture.
87
88# Work so far
89
90## Prototype
91
92I already have a prototype.
93It's quite bug-ridden and has recently developed serious problems actually
94printing after working satisfactorily for a few weeks.
95
96It also does not include a web-interface and I am quite unsatisfied with the
97overall code quality.
98
99The [685 lines of code](https://github.com/AlDanial/cloc) can be found in the
100[repo](http://git.yggdrasil.li/thermoprint?h=master) as well.
101
102## Rewrite
103
104Currently the [rewrite](http://git.yggdrasil.li/thermoprint?h=rewrite&id=1cc1bc4555d1ca7688920027b401ea94f3b82d5f) contains:
105
106[Printout.hs](http://git.yggdrasil.li/thermoprint/tree/spec/src/Thermoprint/Printout.hs?h=rewrite&id=1cc1bc4555d1ca7688920027b401ea94f3b82d5f)
107 ~ A definition of the payload-datatype -- a structured document format meant to be translated into a printer specific representation at print-time
108
109[API.hs](http://git.yggdrasil.li/thermoprint/tree/spec/src/Thermoprint/API.hs?h=rewrite&id=1cc1bc4555d1ca7688920027b401ea94f3b82d5f)
110 ~ A definition of the API. This already encompasses most of the work on the API due to the powerful derivation utilities provided by servant
111
112[bbcode/src](http://git.yggdrasil.li/thermoprint/tree/bbcode/src/Text?h=rewrite&id=1cc1bc4555d1ca7688920027b401ea94f3b82d5f)
113 ~ An already complete parser for bbcode -- a format very closely related to xml
114
115*/test
116 ~ [Unit](https://hackage.haskell.org/package/hspec)- and [QuickCheck](https://hackage.haskell.org/package/QuickCheck)-tests for:
117
118 * The smart constructor [`text`](http://git.yggdrasil.li/thermoprint/tree/spec/src/Thermoprint/Printout.hs?h=rewrite&id=1cc1bc4555d1ca7688920027b401ea94f3b82d5f#n131) for [`Block`](http://git.yggdrasil.li/thermoprint/tree/spec/src/Thermoprint/Printout.hs?h=rewrite&id=1cc1bc4555d1ca7688920027b401ea94f3b82d5f#n83).
119 * The To- and FromJSON instances of `Printout`
120 * The [bbcode lexer](http://git.yggdrasil.li/thermoprint/tree/bbcode/src/Text/BBCode/Lexer.hs?h=rewrite)
121 * The entire [bbcode parser](http://git.yggdrasil.li/thermoprint/tree/bbcode/src/Text/BBCode.hs?h=rewrite)