
Weird, that doesn’t happen to me. What OS are you using?

I have a question about typed Racket, structs, and pattern matching: It seems that Racket can mix up a struct’s type with the type of a field. E.g., the below example gives me a type error although step
is just a variant of the identity function. https://gist.github.com/joergen7/193120a0940efba9295f02e970755e62#file-typed-racket-match-rkt

MacOS

@joergen7 I think you need to use (Struct-Type var)
to get the type of the var
struct.

Poking in the dark: have you en/disabled Emacs keybindings and ‘keybindings in menus’?

I have Enable keybindings in menus (overrides Emacs keybinding)

And Automatically adjust opening square brackets

Ah

The second one is the culprit

Disabling it fixes the issue

I want to create a language that (module+ test (require rackunit))
at the very beginning. But the naive implementation has a scope issue (which makes total sense). For example, check-equal?
in the test submodule is unbound. How do I fix the issue? (preferably hygienically, and also avoiding rackunit
dependency at runtime of non-test submodule).

Not sure if this has something to do with syntax-local-introduce
?

@samdphillips your AOC code is awfully similar to mine :slightly_smiling_face:

This one is tested for Unix and removes trailing spaces in the whole file (not just the selection). Just create a new script and replace the default text with the following: #lang racket/base
(require quickscript
racket/class
racket/string)
(define-script remove-trailing-spaces
#:label "remove-trailing-spaces"
(λ (selection #:editor ed)
(send ed begin-edit-sequence)
(define str (send ed get-text))
(define new-str
(string-join
(map (λ (line) (string-trim line #:left? #f))
(string-split str "\n"))
"\n"))
(send ed erase)
(send ed insert new-str)
(send ed end-edit-sequence)
#f))
(it also plays well with undo
) Not too sure about end of lines for Windows though.

@soegaard2 thanks, I use the struct names also as type names, usually without any problems.

@joergen7 Maybe it’s because there is a (var _)
pattern in match?

Does it work if you call it, say, vari
instead?

yes it does, (I observed that also in the gist). That will be the root cause of my confusion.

Does the same happen if you pick on of the other builtin patterns? https://docs.racket-lang.org/reference/match.html?q=match#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29

let me try …

I just tried quote
instead of var
but get no type error.

hmm, quote might be a bad counterexample though.

If the name var
is to blame, you can use (struct var (pat ...))
instead of (var _)
as the pattern.

yes, I can’t use var
as a struct name. that is the solution to the problem. I also understand why now.

The question is whether it should have worked? @samth

The problem is the treatment of var by match, which is specified to work that way but also seems never to be useful

Yeah, too late to change now.

I’m trying to understand the output of this code

#lang racket
(define (main)
(define p1 (place ch
(sleep 2)
(println "done 2")
(flush-output)
(place-channel-put ch 1)))
(let loop ()
(define e (sync/timeout 10 p1))
(println "done 10 or bail out early")
(flush-output)
(cond
[e (println e)]
[else (loop)])))

which is: "done 10 or bail out early"
"done 2"
1

how is this possible?

Is there a difference if you run it in a terminal (compared to DrRacket)?

Great minds think alike :slightly_smiling_face:. After I posted mine I noticed @yfangzhe’s was pretty similar too.

Yes. DrRacket always have "done 10 or bail out early"
before "done 2"
. Terminal has the opposite order, which makes more sense.

FWIW in racket-mode I get: place-example.rkt> (main)
"done 10 or bail out early"
1
"done 2"

Unfortunately it might be an output buffer issue

The docs of place say there is a thread pumping output from a place to the original output port.

I wonder if you set current-output-port
to a file what would happen?

The question is whether the “pump” gets activated when flush is called.

Well. I mean, we write tests. Which is a good thing in general, but probably not a good way to get high ranking!

Yeah I finished faster than I had in previous years and didn’t make the public leaderboard at all

There is a difference between “file stream ports” and other ports in streamify-out
and streamify-in
which are used by pump-ports
. https://github.com/racket/racket/blob/master/racket/collects/racket/private/streams.rkt#L42

I’m trying to use circleci to auto-deploy my frog blog. There is always errors when raco pkg install --auto frog
, the error messages like: raco setup: --- summary of errors --- [19:12:51]
raco setup: error: during making for <pkgs>/frog/frog
raco setup: instantiate: unknown module
raco setup: module name: #<resolved-module-path:"/usr/share/racket/collects/racket/linklet.rkt">
raco setup: compiling: <pkgs>/frog/frog/private/enhance-body/add-doc-links/doc-uri.rkt
raco setup: error: during making for <pkgs>/frog/frog
raco setup: read-compiled-linklet: version mismatch expected: "7.4" found: "7.5" in: /root/.racket/7.4/pkgs/frog/frog/compiled/enhance-body_rkt.zo
raco setup: compiling: <pkgs>/frog/frog/frog.scrbl
What happened, and how to fix it?

@yfangzhe this is probably related to https://github.com/racket/racket/issues/2928

can you say more about how exactly your CircleCI job runs? Do you have a link to the full log?


hmm, that’s surprising; maybe @notjack who wrote that docker image has ideas

I can’t see the link; it gives me an error

Sorry, not familiar with circleci. Here is the output https://circleci.com/api/v1.1/project/github/yfzhe/yfzhe.github.io/12/output/102/0?file=true&allocation-id=5de4101fb9f6057c3375e296-0-build%2F4D3F8F48

Thanks. There seem to be two things wrong. One is that there’s some confusion between version 7.4 and 7.5; I can’t tell what that docker image contains. Second that bug that I linked seems to be present.

And the lastest version of docker image seems to be Racket 7.4, if it matters.

Looks like 7.4, but is raco pulling a precompiled version of frog?

yes, it appears that it’s downloading something precompiled for the wrong version

I remember trying to get those images to use the precompiled packages served by the package build server

I don’t recall how that turned out

It might be set up so that whichever image is the “latest” version is configured to use the build server, and I haven’t yet updated the racket:latest image to point to 7.5 instead of 7.4.

Pull request for that welcome, it’s a three-line change (or less)

I’m using the readline
library for Racket. I noticed that on OSX readline works as expected, but on Linux (using xterm, at least) I get escape characters. So if I’m autocompleting (say) _ _ _
I get \_ \_ \_
. Any ideas why this would happen on Linux? Maybe something encoding related? My guess is that this isn’t Racket’s fault and is probably something in GNU readline that differs.

note that it probably is using editline on your linux machine unless you’ve installed readline-gpl

oh, good point, Sam.