samth
2017-8-29 12:41:06

@leif seems like you could just have the version on your web page have the corrections in it


joelmccracken
2017-8-29 13:47:53

oh, i think sxml might, thanks @notjack ; fyi @zenspider yes map works fine, but i was hoping to do something like “replace every <a> node with a different node”, which ends up being pretty verbose to do recursively


leif
2017-8-29 13:58:25

@samth Yup. And I will do that soon. But it also seems reasonable to point out the diffs explicitly.


greg
2017-8-29 14:35:22

At the moment, searching for foo on https://pkgs.racket-lang.org/ goes to https://pkgd.racket-lang.org/pkgn/search?q=foo which spins for a minute before giving 502 Proxy Error

Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /pkgn/search.

Reason: Error reading from remote server

Apache/2.4.7 (Ubuntu) Server at <http://pkgd.racket-lang.org\|pkgd.racket-lang.org> Port 443

greg
2017-8-29 14:40:49

Not sure if that’s a bat signal for @jeapostrophe @tonyg @cfinegan or other


greg
2017-8-29 15:21:29

New topic. This surprised me:

$ echo "#lang racket" &gt; lang.rkt

$ echo "(module mod racket)" &gt; mod.rkt

$ racket -e '(require syntax/modread) (with-module-reading-parameterization (λ () (with-input-from-file "lang.rkt" read)))'
'(module lang racket (#%module-begin))

$ racket -e '(require syntax/modread) (with-module-reading-parameterization (λ () (with-input-from-file "mod.rkt" read)))'
'(module mod racket)

That is, #lang files get #%module-begin added on read, but module expression files do not. Even using with-module-reading-parameterization and expand-to-top-form doesn’t add #%module-begin.


greg
2017-8-29 15:21:55

Of course it’s N/A in most cases because you’d probably expand that before rewriting it, like the errortrace and gui-debugger annotators do, and that will add the #%module-begin. (I just had an odd situation where I can’t expand the whole thing.) ¯_(ツ)_/¯


samth
2017-8-29 15:26:23

here, with-module-reading-parameterization won’t change that, because read in the second case is really just producing some s-expressions


samth
2017-8-29 15:26:46

expand-to-top-form doesn’t change that because module is a top-form


samth
2017-8-29 15:28:42

I think the difference is that the reader for #lang (or maybe for racket) adds the #%module-begin, not some part of read itself


jimmy
2017-8-29 16:18:20

@jimmy has joined the channel


zenspider
2017-8-29 22:11:58
(define/match (board-ref . args)
  [(r c) (board-ref board (-&gt;coord r c))]
  [(rc)  (hash-ref (board-b board) rc)])

;; battleship.rkt:42:3: match: wrong number of match clauses, expected 1 and got 2
;;   in: (r c)

clue me? I thought dotting the args was the right way to do variable arity


zenspider
2017-8-29 22:12:26

also really confused why that is about the number of clauses… not the pattern itself?


notjack
2017-8-29 22:15:45

I think you want ((list* r c)) instead of (r c)


jaz
2017-8-29 22:15:47

First, I think the number of sub-patterns in each match*-pattern needs to be the same — and needs to be equal to the number of arguments, where the rest argument counts as 1.


notjack
2017-8-29 22:15:54

or ((cons r c))


zenspider
2017-8-29 22:16:03

same as: [(`(,r ,c)) (board-ref board (->coord r c))], yes?


zenspider
2017-8-29 22:16:06

gah


zenspider
2017-8-29 22:16:17

damnit


notjack
2017-8-29 22:16:28

generally I avoid quoting in match patterns, they’re a complex enough grammar as is


notjack
2017-8-29 22:16:38

unless matching against something with lots of symbolic literals I want to ignore


zenspider
2017-8-29 22:19:11

I got tangled up rewriting this and forgot the board argument… now it passes tests:

(define/match (board-ref . args)
  [(`(,board . (,r ,c))) (board-ref board (-&gt;coord r c))]
  [(`(,board . (,rc)))  (hash-ref (board-b board) rc)])

zenspider
2017-8-29 22:19:27

I’m not sure how to say that in non-quotey form. cons… list* ?


jaz
2017-8-29 22:20:17

list-rest?


jaz
2017-8-29 22:21:36

well, the first one could just be list


notjack
2017-8-29 22:22:28

FWIW maybe a define/convert utility would be appropriate:

(define/convert (board-ref b (rc #:convert -&gt;coord))
  (hash-ref (board-b board rc)))

zenspider
2017-8-29 22:23:14

I’ve never seen that… cool, thanks


zenspider
2017-8-29 22:23:30

wait. I’ve never seen that because it doesn’t exist?


notjack
2017-8-29 22:23:40

it doesn’t, I’m hypothesizing


zenspider
2017-8-29 22:23:44

haha


notjack
2017-8-29 22:23:52

I don’t think it’d be tricky to make though


notjack
2017-8-29 22:26:08

oh wait you’re using multiple arguments to mean a list?


zenspider
2017-8-29 22:26:21

ok. they can both be plain list patterns… that does seem cleaner


notjack
2017-8-29 22:26:34

how is board-ref supposed to be called exactly? either (board-ref b r c) or (board-ref b coord)?


zenspider
2017-8-29 22:27:09
(define/match (board-ref . args)
  [((list board r c)) (board-ref board (-&gt;coord r c))]
  [((list board rc))  (hash-ref (board-b board) rc)])

;; vs

(define/match (board-ref . args)
  [(`(,board ,r ,c)) (board-ref board (-&gt;coord r c))]
  [(`(,board ,rc))  (hash-ref (board-b board) rc)])

zenspider
2017-8-29 22:27:46

yes, both. I’m gonna have to use one for a wire protocol and don’t want to write string-&gt;coords but I want to write clean and easy tests and internal playtesting


zenspider
2017-8-29 22:29:40

is there a parameter or something to un-truncate test failure output?


notjack
2017-8-29 22:30:09

for rackunit? how is your output being truncated?


zenspider
2017-8-29 22:31:13

the error coming up for match failures includes the call args, which is a 10x10 board… but the tail is the important part for me


notjack
2017-8-29 22:31:27

ohhh


zenspider
2017-8-29 22:31:33

moot point now, but I’d like to roll that up in some handler


notjack
2017-8-29 22:31:53

I’d be surprised if there’s a way to do that at all


notjack
2017-8-29 22:32:13

you could make your board print differently with gen:custom-write


zenspider
2017-8-29 22:32:23

boo


notjack
2017-8-29 22:33:54

huh, there’s no define/case built in to racket for use with case-lambda


zenspider
2017-8-29 22:35:14

huh. haven’t used that one either… not sure when I’d want to pick that over the match one


notjack
2017-8-29 22:36:32

case-lambda will report better arity information in this case


notjack
2017-8-29 22:37:08

the define/match form constructs a function with an arity claiming to accept any number of arguments, but I think case-lambda is smarter than that and makes a function that knows it accepts either two or three arguments


notjack
2017-8-29 22:37:48
(define-simple-macro
  (define/case f:id (~and clause [(arg:id ...) body:expr ...+]) ...)
  (define f (case-lambda clause ...)))

(define/case board-ref
  [(b r c) (board-ref b (-&gt;coord r c))]
  [(b rc)  (hash-ref (board-b b) rc)])

zenspider
2017-8-29 22:40:52

yeah.. the arity mismatch message truncates the one arg and shows the rest. that’s nice


zenspider
2017-8-29 22:40:56
(define-simple-macro (define/case name (formals body ...+) ...)
  (define name (case-lambda [formals body ...] ...)))

(define/case board-ref2
  [(board r c) (board-ref2 board (-&gt;coord r c))]
  [(board rc)  (hash-ref (board-b board) rc)])

zenspider
2017-8-29 23:12:10

Is there a cleaner/better way of saying either of these things?

(define (board-&gt;string board)
  (string-join
   (for/list ([r (in-list rows)])
     (string-join
      (for/list ([c (in-list cols)])
        (-&gt;marker (board-ref board r c)))))
   "\n"))

(module+ test
  (check-equal? (board-&gt;string (make-board))
                (string-join
                 (for/list ([r (in-list rows)])
                   ". . . . . . . . . .")
                 "\n")))

zenspider
2017-8-29 23:12:34

I want to have something like build-string that takes a proc that returns strings (or just a string duplicated N times)


zenspider
2017-8-29 23:12:51

Basically Ruby’s String#*


zenspider
2017-8-29 23:13:01

but board-&gt;string also feels stilted


zenspider
2017-8-30 00:39:58

there’s a bug in GUI’s rectangles:

(require racket/gui/base)

(define (draw-box broken)
  (define canvas (make-bitmap 51 28))
  (define dc (send canvas make-dc))

  (send dc set-brush "WhiteSmoke" 'solid)

  (send dc set-pen "black" (if broken 1 2) 'long-dash)

  (send dc draw-rectangle 1 1 50 25)

  canvas)

(printf "only dashed on the sides:~n")
(draw-box 'broken)
(printf "correctly dashed, but needs to be 2x wide:~n")
(draw-box #f)

notjack
2017-8-30 00:56:16

@zenspider there might be a way to use math/array to do that more cleanly, but it might also be a hassle


notjack
2017-8-30 01:48:13

are all packages in the main distribution hosted in github repos under the “racket” organization?


samth
2017-8-30 01:51:35

@notjack there are maybe a couple exceptions


notjack
2017-8-30 01:52:33

@samth if new packages were added to the main distribution though, they’d go under the racket org?


samth
2017-8-30 01:53:07

that depends if they already existed someewhere else


samth
2017-8-30 01:53:15

in which case they would maybe stay there


samth
2017-8-30 01:53:26

there aren’t really any rules here


notjack
2017-8-30 01:57:23

gotcha