Skip to content

Commit 1214dad

Browse files
committed
Add third prototypical example
1 parent 57d6866 commit 1214dad

File tree

3 files changed

+230
-24
lines changed

3 files changed

+230
-24
lines changed

README.md

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,6 @@ programming code, but it is nevertheless a formally defined specification for
1616
writing procedures and clear rules for executing them and recording their
1717
outcomes.
1818

19-
Documents written in Technique have file extension _\*.tq_.
20-
21-
## Examples
22-
23-
To give a sense of the flavour of the language, here are two examples.
24-
25-
First, from a set of instructions guiding staff of what to do when an incident
26-
occurs:
27-
28-
<a href="examples/prototype/DontPanic.tq">
29-
<img width=890 src="examples/screenshots/DontPanic.png">
30-
</a>
31-
32-
Second, shows using Technique to describe a much larger procedure, in his case
33-
the entire process of doing systems engineering on a software project. This
34-
pushes the limits of what Technique is for, but nevertheless illustrates that
35-
it can be used for very large structures as well as very detailed ones:
36-
37-
<a href="examples/prototype/SystemsEngineeringProcess.tq">
38-
<img width=900 src="examples/screenshots/SystemsEngineeringProcess.png">
39-
</a>
40-
41-
Detailed examples can be found in the _examples/_ and _tests/_ directories.
42-
4319
## Contents
4420

4521
This repository contains the _technique_ binary, which is the compiler for
@@ -58,3 +34,34 @@ for Zed, with VS Code and NeoVim on the way.
5834
<https://github.com/technique-lang/tree-sitter-technique>
5935
- Typst and Vim support \
6036
<https://github.com/technique-lang/highlighting>
37+
38+
## Examples
39+
40+
To give a sense of the flavour of the language, here are a small selections of
41+
examples Technique files renderer to PDFs.
42+
43+
First, from a the recipe for a roast turkey during the holidays:
44+
45+
<a href="examples/prototype/ChristmasTurkey.tq">
46+
<img width=608 src="examples/screenshots/ChristmasTurkey.png">
47+
</a>
48+
49+
This from a set of instructions guiding staff of what to do when an incident
50+
occurs:
51+
52+
<a href="examples/prototype/DontPanic.tq">
53+
<img width=593 src="examples/screenshots/DontPanic.png">
54+
</a>
55+
56+
Finally, an example showing using Technique to describe a much larger
57+
procedure, in this case the entire process of doing systems engineering on a
58+
software project. This pushes the limits of what the language is for, but
59+
nevertheless illustrates that Technqiue can be used for very large structures
60+
as well as very detailed ones:
61+
62+
<a href="examples/prototype/SystemsEngineeringProcess.tq">
63+
<img width=600 src="examples/screenshots/SystemsEngineeringProcess.png">
64+
</a>
65+
66+
Detailed examples can be found in the _examples/_ and _tests/_ directories.
67+
Documents written in Technique have file extension _\*.tq_.
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
% technique v1
2+
! Proprietary; © 2002-2019 Andrew Cowie
3+
4+
christmas_dinner : Context -> Dinner
5+
6+
# Christmas Dinner
7+
8+
Recipe for a classic Christmas dinner. It is probably worth noting that this
9+
can be followed on most any high holiday. The only things you really need are
10+
patience, guests, and a turkey.
11+
12+
1. Assemble ingredients <assemble_ingredients> ~ ingredients
13+
2. Prepare the meal <prepare_meal>(ingredients) ~ meal
14+
3. Serve dinner <serve_dinner>(meal) ~ dishes
15+
4. Clean up after <cleanup_after>(dishes)
16+
17+
assemble_ingredients : () -> Ingredients
18+
19+
# Shopping List
20+
21+
Assembling all necessary ingredients from various sources.
22+
23+
@chef
24+
1. Get turkey from butcher { <turkey> ~ t }
25+
2. Get stuffing ingredients { <stuffing> ~ s }
26+
3. Get breadsauce ingredients { <breadsauce> ~ b }
27+
28+
turkey : () -> Ingredients
29+
30+
# Turkey
31+
32+
For some reason people seem to think that they need an enormous bird. Don't
33+
worry even if you are expecting a large party; if you've got lots of relatives
34+
you can just leave out a few plates of cheese and crackers and they'll be full
35+
long before dinner is served.
36+
37+
^butcher
38+
- Buy turkey
39+
{
40+
[
41+
"Turkey" = 4 ± 1 kg
42+
"Bacon" = 2 pieces
43+
]
44+
}
45+
46+
stuffing : () -> Ingredients
47+
48+
# Stuffing
49+
50+
Stuffing a bird actually makes it take longer to cook, but doing so adds
51+
aroma, flavour, and helps preserve moisture and keeps the turkey tender.
52+
53+
^store
54+
- Get seasoning ingredients
55+
{
56+
[
57+
"Salt" = 1 teaspoon
58+
"Pepper" = 1 teaspoon
59+
]
60+
}
61+
62+
^grocer
63+
- Get vegetables
64+
{
65+
[
66+
"Carrots" = 1 each
67+
"Celery" = 0.5 stalk
68+
]
69+
}
70+
71+
^bakery
72+
- Get bread
73+
{
74+
[
75+
"Bread" = 2 slices
76+
]
77+
}
78+
79+
breadsauce : () -> Ingredients
80+
81+
# Breadsauce
82+
83+
This ancient recipe from Northern Yorkshire calls for ...
84+
85+
^bakery
86+
- Get bread
87+
{
88+
[
89+
"Bread" = 4 slices
90+
]
91+
}
92+
93+
^store
94+
- Get spices and milk
95+
{
96+
[
97+
"Salt" = 1 teaspoon
98+
"Pepper" = 1 teaspoon
99+
"Cloves" = 4 teaspoons
100+
"Milk" = 100 mL
101+
]
102+
}
103+
104+
^grocer
105+
- Get onion
106+
{
107+
[
108+
"Brown Onion" = 0.5 bulb
109+
]
110+
}
111+
112+
prepare_meal(i) : Ingredients -> Meal
113+
114+
# Prepare Meal
115+
116+
Coordinating the preparation of all meal components.
117+
118+
@chef
119+
1. Roast the turkey { <roast_turkey>(i) ~ turkey }
120+
2. Roast potatoes { <roast_potatoes>(i) ~ potatoes }
121+
3. Make breadsauce { <make_breadsauce>(i) ~ sauce }
122+
4. Prepare vegetables { <prepare_vegetables>(i) ~ raw }
123+
5. Make gravy { <make_gravy>(i) ~ gravy }
124+
6. Wait for cooking { timer(3 hr) ~ t1 }
125+
7. Cook vegetables { <cook_vegetables>(raw) ~ (veggies, water) }
126+
8. Combine gravy with vegetable water { <combine>(gravy, water) ~ gravy }
127+
9. Check turkey temperature { <probe_bird_temperature>(turkey) ~ temp }
128+
{
129+
[
130+
"Final Temperature" = temp
131+
]
132+
}
133+
134+
roast_turkey(i) : Ingredients -> Turkey
135+
136+
# Roast Turkey
137+
138+
@chef
139+
1. Set oven temperature { <oven>(180 °C) ~ temp }
140+
2. Place bacon strips onto bird
141+
3. Put bird into oven
142+
4. Set timer for roasting { timer(3 h) ~ t }
143+
5. Record temperature
144+
{
145+
[
146+
"Roast temperature" = temp
147+
]
148+
}
149+
150+
@assistant
151+
- Set the table
152+
153+
cook_vegetables(veg) : VegetablesPrepared -> VegetablesCooked, VegetableWater
154+
155+
# Cook Vegetables
156+
157+
@chef
158+
1. Boil water
159+
2. Dunk greens in water
160+
161+
combine(g, w) : Gravy, VegetableWater -> Gravy
162+
163+
# Pour the vegetable water into the gravy
164+
165+
@chef
166+
- Combine gravy and vegetable water
167+
168+
serve_dinner(m) : Meal -> DirtyDishes
169+
170+
# Serve dinner and enjoy
171+
172+
cleanup_after(d) : DirtyDishes -> ()
173+
174+
# Cleanup
175+
176+
No one likes cleaning up. As far as I can tell, the only real justification
177+
for having children is to help with doing the dishes on festive occasions.
178+
Certainly I always hated my Aunt at holidays for making me dry dishes with a
179+
dish towel when they would perfectly well air dry by themselves.
180+
181+
@*
182+
1. Turn off oven { <oven>(0 °C) }
183+
2. Put knives away { <knives_away> }
184+
3. Turn lights out { <lights_out> }
185+
186+
oven(temp) : Temperature -> ()
187+
188+
# Set oven temperature
189+
190+
@chef
191+
- Set temperature to { "oven at { temp }" }
192+
193+
knives_away :
194+
195+
# Put knives away
196+
197+
@*
198+
1. Place knives in safe place
199+
2. Start dishwasher
137 KB
Loading

0 commit comments

Comments
 (0)