Chapter 11: Practical Translation Challenge
Just looking will make you forget, only by doing will you remember. This chapter does not provide a standard answer - we will give you the original configuration, and ask you** to handwrite the equivalent SML**, and then click “verify” to let the parser judge in real time.
These challenges deliberately chose common formats in engineering (Caddyfile/Docker compose/nginx), which are highly similar to SML’s “block+key value” thinking. Remember three things when translating:
-
Block=Block:
name { }is universal on both sides; -
Key value pairs:
key value(Caddy/nginx) orkey: value(YAML) both correspond to SML’skey: value; -
Array: SML uses
[ a b c ](comma can be omitted), YAML uses[a, b, c].
Here are three challenges with increasing difficulty. Write SML directly in the white background editor on the right side of each question, and any errors or missing fields will be immediately prompted.
Challenge 1: Caddyfile → SML
key value to key: value. After completion, click 'Verify' and the system will check if all key fields are translated correctly. The verification logic is JS directly parsing your SML and asserting the result.example.com {
reverse_proxy localhost:8080
tls internal
encode gzip
}
Challenge 2: Docker compose → SML (high difficulty)
[a, b] of : YAML is written as [ a b ] in SML; The key names with hyphens (such as container_name) can be directly used as bare word keys. Verification will check the key fields of services.web and services.db.services:
web:
image: nginx:1.27
ports:
- "80:80"
depends_on:
- db
db:
image: postgres:16
environment:
POSTGRES_PASSWORD: secret
Challenge 3: nginx.conf → SML (high difficulty)
listen 80; == SML listen: 80; location/{ } are nested blocks; proxy_pass http://app; is a value with spaces and requires quotation marks. Verify the key instructions for checking the server block.server {
listen 80;
server_name example.com;
location / {
proxy_pass http://app:3000;
}
location /api {
proxy_pass http://api:4000;
}
}
Why did you do this
Translating other formats into SML can best test whether you truly understand that ‘SML is just a tree’. When you can intuitively map any configuration into an Block/Key/Array three piece set, you have already mastered the essence of SML.