Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matching in required structs #91

Open
gpoesia opened this issue Oct 6, 2020 · 3 comments
Open

Matching in required structs #91

gpoesia opened this issue Oct 6, 2020 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@gpoesia
Copy link

gpoesia commented Oct 6, 2020

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?

@dedbox
Copy link
Owner

dedbox commented Oct 7, 2020 via email

@gpoesia
Copy link
Author

gpoesia commented Oct 7, 2020

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

@dedbox dedbox added the bug Something isn't working label Oct 7, 2020
@dedbox dedbox self-assigned this Oct 7, 2020
@dedbox
Copy link
Owner

dedbox commented Oct 13, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants