Stream: show and tell

Topic: patching interpreter


view this post on Zulip nandi (Dec 24 2025 at 23:42):

Been patching the interpreter to play around with different things came up with this today

nandi@ubuntu-16gb-hel1-1:~/code/roc-platform-template-zig$ cat examples/list.roc
app [main!] { pf: platform "../platform/main.roc" }

import pf.Stdout
import pf.Http

main! = |args| {
    url = args.get(1)?
    Stdout.line!("Fetching ${url} ...")
    resp = Http.get!(url)
    Stdout.line!("requestUrl: ${resp.requestUrl}")
    Stdout.line!("statusCode: ${resp.statusCode.to_str()}")
    Stdout.line!("responseBody length: ${resp.responseBody.len().to_str()}")
    Stdout.line!("responseHeaders: ${resp.responseHeaders.to_str()}")
    #Stdout.line!("all: ${resp.to_str()}")

    s = resp.responseBody.take_first(100).to_str()?
    Stdout.line!("Response body (first 100 bytes):")
    Stdout.line!(s)
    Ok({})
}
nandi@ubuntu-16gb-hel1-1:~/code/roc-platform-template-zig$ zig build x64musl && ../roc/zig-out/bin/roc examples/list.roc --no-cache
 -- https://roc-lang.org
Fetching https://roc-lang.org ...
requestUrl: https://roc-lang.org
statusCode: 200
responseBody length: 91598
responseHeaders: {"Date": "Wed, 24 Dec 2025 23:39:32 GMT", "Content-Type": "text/html", "Transfer-Encoding": "chunked", "Connection": "keep-alive", "CF-Cache-Status": "HIT", "Cache-Control": "public, max-age=0, must-revalidate", "Nel": "{"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}", "Vary": "accept-encoding", "Report-To": "{"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=bUu8oPADN9K9xf%2B2tnwTNqht4Pp2EMBu8DncG60gwAGc5MXG0l%2FaQKsPPTngbWFzBNqiYaEgGDyLIdNws1mpfxEGyeyfDojBdb27oai7WL97kzu0FaNB1A%3D%3D"}]}", "ETag": "W/"25e1420cbd6551c0239297ea57a34c96"", "Content-Encoding": "gzip", "Server": "cloudflare", "CF-RAY": "9b33f045e8a3dbf4-FRA", "alt-svc": "h3=":443"; ma=86400"}
Response body (first 100 bytes):
<!DOCTYPE html><html  lang="en" class="no-js"><head><meta  charset="utf-8"><title>The Roc Programmin

Last updated: Jan 12 2026 at 12:19 UTC