dedbox/racket-algebraic

Matching in required structs

gpoesia opened this issue · 3 comments

Hi,

I'm new to Racket, so this is likely my mistake. But is it a known limitation that function can't deconstruct structs that come from another file?

Here's a minimal example to illustrate.

If we have a single file:

#lang algebraic/racket/base

(struct S (a))

(define f
  (function
    [(S a) a]
    [_ 0]))

(printf "= ~a\n" (f (S 1)))

It prints 1, as desired. But now, if we move the declaration of S to another file, and require it from this one, then it prints 0 (doesn't match anymore).

If it is a known limitation, is there a way around it?

Hi Eric,

That would be awesome! Thank you for all your work in Algebraic Racket - I'm having a lot of fun with it and Racket in general, recently.

I think I'm still quite behind in my Racket journey, but I'd love to understand in more detail. I tried a little bit to use DrRacket's macro stepper to see which primitives you used in the matching code and try to understand what changes between modules, but I didn't go very far. If you have pointers, I'm curious to know more.

Thanks again,

Gabriel

There's been a snag. I can't reproduce the bug on my end. Fortunately, the package needs an overhaul anyway, to ensure these sorts of issues have been dealt with cleanly. I'll do my best to narrate what I find, why they're problematic w.r.t. to scoping issues, and how things change to deal with it.

In case you'd like to follow along, I'll keep a clean and granular commit log on the better-hygiene branch and use the discussion here to track interesting changes.

At this point, better-hygiene is even with master.