
if you’re not on the mailing list, how does one procure stickers?

Hello! If I want to check the shape of JSON or XML data, I can use some kind of schema validator. I’d like to do the same kind of validation in Racket, except instead of checking the shape of JSON or XML, I’d like to check S-expressions. What would be the idiomatic Racket way for checking such a thing? A giant cond
, or maybe pattern matching, … ?

alexeld: see the recent clojure.spec


d_run: I’d ask @ben.

ty ty

@alexeld: Contracts are most likely what you want.

To specify an sexp shape that is a list of a symbol, followed by two integers, you’d want: (list/c symbol? integer? integer?)

For example.

@stamourv Great, thank you! Would a contract also allow me to flag something like this as invalid: (foo (bar 1) (bar 2))
(repetition of more than one bar
is illegal).

Not directly. But you could do something like: (and/c <the-shape-contract> (lambda (sexp) <function-that-checks-other-properties>))

What would be nice for that would be a datum-parse
with datum-classes
. Like syntax-parse
, but for plain data. Unfortunately, that doesn’t exist.

@stamourv Yep, seems many of the utilities are designed to go <some-non-lispy-format> —> s-exprs
, where you prevent yourself from this mess in the first place during the translation.

Right now I’m recurring over the s-expr, collecting identifiers I’ve seen before, and checking if they appear again. It works, but I can absolutely see more edge cases creeping in later…

I had to do the same thing in the past and I used syntax-parse
. It turns out it handles datums just fine. They are converted to syntax objects, but nothing that a syntax->datum
doesn’t solve. It is probably a bad solution, because the documentation for syntax-parse
doesn’t even document this feature. But it is a solution.

@leafac: I’ve done that too, but it’s a bit awkward.

@stamourv: Good to know that at least I’m not alone :slightly_smiling_face: I believe in my case it was a little less awkward because the datums I was parsing were an embedded DSL (S-expression-based representation of CSS that my program generates and I was compiling to actual CSS).

Thanks @leafac, I’ll check out syntax-parse
. I think what’s making this a bit tricky is that I can guarantee the s-exprs I’m processing to be syntactically valid, it’s the attached meaning that’s the problem.

Sure. But when we all find out that it was a bad idea to shoehorn syntax-parse
in that way, don’t blame me. I warned you :stuck_out_tongue:

Gotcha! ;~)

@mflatt Your “pico” expander implementation https://raw.githubusercontent.com/mflatt/expander/pico/main.rkt looks like it has the quadratic behaviour that Dybvig/Hieb/Bruggeman ’92 avoids — is that right? Is a similar “lazy” approach to scope manipulation needed for the production implementation?

@mflatt (It’s really cool, btw. Great self-contained way of explaining the idea.)

@tonyg Yes; I forget the progression, but it may be that lazy propagation shows up only in the full implementation

To confirm, I see that the “demi” version has a FIXME comment about how laziness is needed; see apply-scope
in “syntax/scope.rkt” in the full version

Oh I see! Silly me, I should have checked the other branches. Thanks @mflatt.

@gknauth has joined the channel

@mflatt Did you make any changes to the bytecode verifier lately?

I ask because in the current HEAD, the following runs correctly, but after its compiled it claims to be ill-formed bytecode:


In version 6.7 it seems to be working fine though.

#lang racket/base
(define ill
(let ((base (string-append "a")))
(λ (x) (string-append base x))))
(ill "b")

Oh, I do get this issue on 6.7, but not 6.6

So I think this merits a mailing list post

@mflatt hmm…I think its ad230d2c
that might have been where the issue started


@leif looking at that now

thanks

@asumu: Do you still have your instance of rudybot running somewhere?

If so, it should probably join slack via the IRC gateway. :)

CC: @offby1

Not anymore. The machine it was hosted on no longer exists.

Unfortunate.

(I have the dockerfile that builds and boots it somewhere though)

Promising!