joe_anonimist
2017-9-6 11:31:05

@joe_anonimist has joined the channel


ivana
2017-9-6 20:18:07

@ivana has joined the channel


cfinegan
2017-9-6 20:35:15

Is there a way to define a macro that can be dropped into a match statement? I’m working with very deeply-nested JSON and I want to be able to define something like this:

(define-simple-macro (Range Start:id End:id)
  (hash-table ['start (? number? Start)]
              ['end (? number? End)]))

So that I can do this:

(match some-hash-table
  [(Range my-start my-end)
   (+ my-start my-end)])

But when I try it, match throws a syntax error, complaining about the expr (Range my-start my-end). Is there a reason this isn’t allowed?


jaz
2017-9-6 20:37:52

@cfinegan define-match-expander



cfinegan
2017-9-6 20:38:51

thank you this is perfect!


sorawee
2017-9-6 20:47:40

Sorry if this has been discussed before: why does (* 0 +inf.0) results in 0 rather then NaN?


lexi.lambda
2017-9-6 21:05:34

@sorawee For no reason other than multiplying anything by exact 0 is exact 0. (* 0.0 +inf.0) is +nan.0.


stamourv
2017-9-6 21:09:57

(add1 @lexi-lambda)


royall
2017-9-7 01:15:11

I’m in the process of building a library that’s shaping up to have ~10 source files. Is there a standardized way of arranging tests for them in the Racket world? I’m thinking I could test them all in a test.rkt, or put a related test module into each source file, or put separate test files into a private/tests directory.


royall
2017-9-7 01:15:24

Additional test module inside each file seems the cleanest in my mind


royall
2017-9-7 01:16:07

Although that would change the runtime deps to include rackunit, wouldn’t it?


notjack
2017-9-7 01:24:19

@royall there’s generally three ways to do this, depending on how heavyweight the tests are


notjack
2017-9-7 01:24:54

First, test submodules. That works for most simple tests.


notjack
2017-9-7 01:26:43

Second, you may include a tests directory in your package. That packages deps are automatically ignored for consideration in “runtime-deps”, so you may write your tests as normal Racket files (you don’t need to put all the code in submodules).


notjack
2017-9-7 01:28:50

Third, make a wholly separate foo-test package for your foo package. This is typically done when the libraries used for testing are too expensive to include even as only build-deps, either because you’re using multiple heavyweight packages only for testing or your package is used by a lot of other packages so minimizing its dependencies is really important


royall
2017-9-7 01:32:32

Thanks! Test submodule sounds good for this project


royall
2017-9-7 01:32:56

Especially after reading this: >The test submodule imports rackunit for its check form, but that import does not create a dependency on rackunit (which is a substantial library) for modules that import “fish2.rkt”; the dependency is only for the test submodule.


notjack
2017-9-7 01:33:58

Right, submodule dependencies are different from the dependencies of their parent modules