laurent.orseau
2019-12-1 08:36:22

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


joergen7
2019-12-1 08:40:12

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


sorawee
2019-12-1 09:28:34

MacOS


soegaard2
2019-12-1 10:11:18

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


laurent.orseau
2019-12-1 10:15:56

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


sorawee
2019-12-1 10:27:10

I have Enable keybindings in menus (overrides Emacs keybinding)


sorawee
2019-12-1 10:27:38

And Automatically adjust opening square brackets


sorawee
2019-12-1 10:28:11

Ah


sorawee
2019-12-1 10:28:24

The second one is the culprit


sorawee
2019-12-1 10:28:33

Disabling it fixes the issue


sorawee
2019-12-1 11:28:26

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).


sorawee
2019-12-1 11:29:06

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


sorawee
2019-12-1 11:30:50

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


laurent.orseau
2019-12-1 11:51:05

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.


joergen7
2019-12-1 15:04:34

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


soegaard2
2019-12-1 15:06:07

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


soegaard2
2019-12-1 15:06:25

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


joergen7
2019-12-1 15:08:16

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


soegaard2
2019-12-1 15:09:27

joergen7
2019-12-1 15:10:19

let me try …


joergen7
2019-12-1 15:11:27

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


joergen7
2019-12-1 15:12:19

hmm, quote might be a bad counterexample though.


soegaard2
2019-12-1 15:13:42

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


joergen7
2019-12-1 15:14:15

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


soegaard2
2019-12-1 15:26:46

The question is whether it should have worked? @samth


samth
2019-12-1 15:27:39

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


soegaard2
2019-12-1 15:58:59

Yeah, too late to change now.


sorawee
2019-12-1 18:13:46

I’m trying to understand the output of this code


sorawee
2019-12-1 18:13:53

#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)])))


sorawee
2019-12-1 18:14:17

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


sorawee
2019-12-1 18:15:18

how is this possible?


soegaard2
2019-12-1 18:20:05

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


samdphillips
2019-12-1 18:23:26

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


sorawee
2019-12-1 18:25:52

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


soegaard2
2019-12-1 18:28:31

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


samth
2019-12-1 18:28:48

Unfortunately it might be an output buffer issue


soegaard2
2019-12-1 18:29:18

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


samdphillips
2019-12-1 18:32:24

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


soegaard2
2019-12-1 18:35:30

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


sorawee
2019-12-1 18:35:38

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


samdphillips
2019-12-1 18:37:44

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


soegaard2
2019-12-1 18:39:54

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


yfangzhe
2019-12-1 19:16:06

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?


samth
2019-12-1 19:22:12

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


samth
2019-12-1 19:28:57

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



samth
2019-12-1 19:41:20

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


samth
2019-12-1 19:41:29

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



samth
2019-12-1 19:49:23

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.


yfangzhe
2019-12-1 19:49:38

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


samdphillips
2019-12-1 19:50:29

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


samth
2019-12-1 19:57:34

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


notjack
2019-12-1 20:41:29

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


notjack
2019-12-1 20:41:36

I don’t recall how that turned out


notjack
2019-12-1 20:42:50

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.


notjack
2019-12-1 20:43:13

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


krismicinski
2019-12-1 22:05:37

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.


samth
2019-12-1 22:06:26

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


krismicinski
2019-12-1 23:38:37

oh, good point, Sam.