Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 104 lines (91 sloc) 3.499 kB
fccc685 Initial open-source release
MLstate authored
1 /**
2 * Boiling water and preparing tea.
3 *
4 * @author David Rajchenbach-Teller, 2009-2010
5 * @author Gregoire Makridis, 2010 (added support for Roibos)
6 * @category food
7 * @destination public
8 */
9
10 /**
11 * {1 About this module}
12 *
13 * This module contains a high-level interface for boiling water and preparing tea.
14 * If you wish to prepare tea, this is probably the module you are looking for.
15 *
16 *
17 * {1 Where should I start?}
18 *
19 * If you simply want to prepare some tea, use function [Tea.prepare].
20 *
21 *
22 * {1 What if I need more?}
23 *
24 * Some teas need careful preparations, e.g. Black Tea should be prepared with hot
25 * water, just boiled, at 95 Celcius, and should infuse for 3 minutes. Other teas
26 * require the water to be at 80 Celcius or to infuse for 5 minutes. If you need fine
27 * control on the temperature of water and infusion, you can obtain more control on
28 * tea preparation by using more powerful functions [Tea.boil], [Tea.infuse] and
29 * [Tea.serve].
30 *
31 * Sometimes, you may also need to validate the leaves you have, e.g. to check whether
32 * they are real tea or some substitute such as herbal tea or roibos. For this purpose,
33 * use [Tea.get_variety].
34 *
35 * If this is not sufficient, you may need to use lower-level module [Drinks].
36 */
37
38 /**
39 * {1 Types defined in this module}
40 */
41
42 /**
43 * Varieties of tea.
44 */
45 type Tea.variety = {dark} / {green} / {white}
46 / {red} /**So-called "red tea". Note that this is not actual tea.*/
47
48
49 type Tea.status = {ready} / {infusing} / {boiling}
50
51 /**
52 * Some tea or variant of tea.
53 */
54 @abstract type Tea.tea = ...
55
56 /**
57 * The result of preparing tea.
58 */
59 type Tea.preparation = {success: Drinks.cup} /**Your tea is ready and served.*/
60 / {not_enough_tea} /**There isn't enough tea in the reserve to prepare tea.
61 In such circumstances, you should call [Mehdi.please] to
62 obtain more tea.*/
63 / {tastes_like_coffee}/**Something is wrong with the contents of the cup. Presumably,
64 this is not tea.*/
65 / {theine_intoxication} /**OPA's runtime security handler has determined that you have
66 drunk too much tea since you last went home. Perhaps you should
67 go home.*/
68 / {no_water_available} /**For some reason, there is no water at this floor. You
69 will need to look for water in other floors.*/
70 / {no_electricity_available}/**For some reason, the electricity is out in the building.
71 You should find something else to do.*/
72
73 Tea =
74 {{
75 /**
76 * {1 High-level interface}
77 */
78
79 /**
80 * Complete preparation of tea.
81 *
82 * @param tea A tea which need to be prepared. This can be either a real tea or some near-tea. Note that
83 * the reserve of tea must contain some of this tea, otherwise this function will produce [{not_enough_tea}].
84 *
85 * @return Either [{success = cup}] if preparation succeeded or some error otherwise. See [Tea.preparation]
86 * for the detail on errors.
87 */
88 prepare(tea: Tea.tea) : Tea.preparation =
89 ...
90
91 /**
92 * {1 Lower-level interface}
93 */
94 //...
95 }}
96
97 /**
98 * {1 Functions exported to the global namespace}
99 */
100
101 /**
102 * (none)
103 */
Something went wrong with that request. Please try again.