sarna.dev
2021-3-14 10:09:14

@sarna.dev has joined the channel


advait.raykar
2021-3-14 13:06:52

Hi, I wanted to know if it is possible to create gRPC APIs for streaming in Racket. If not, does anyone know how I could help with creating such a framework or library for Racket. I think it would be really nice.


rokitna
2021-3-14 13:50:23

Hmm, I haven’t seen any streaming APIs in Racket yet. (The Overscan package seems to deal with streaming media, but that’s probably not what you’re looking for.)


samth
2021-3-14 14:49:34

you might be interested in https://github.com/endobson/racket-grpc


pihentagy
2021-3-14 19:32:48

What is the correct way to have “tuples” in typed racket?


notjack
2021-3-14 19:49:35

Use structs? Unsure what your requirements for tuples are.


pihentagy
2021-3-14 19:51:48

I have a function returning multiple values and thought that would be a good ide to return as a tuple. ITMT I’ve found I can have heterogeneous list, like (List Integer Integer Char String)


capfredf
2021-3-14 19:53:20

you can just use values if you don’t need to pass them around as a whole


jjlammi
2021-3-14 21:19:47

@soegaard2 I have tried a little bit urlang. Is it not possible to use printf, format, round, floor, string-append etc within urlang block for defined procedures, even with urlang/extra ? I found that causes unbound errors as I made following script: jarmo$ cat funcs.rkt #lang racket (require urlang urlang/extra) (require racket/date) (current-urlang-run? #t) (current-urlang-echo? #t) (current-urlang-console.log-module-level-expr? #t) (displayln (urlang (urmodule funcs (define (ctof cdeg) (+ 32 (* 1.8 cdeg))) (define (ftoc fdeg) (/ (- fdeg 32) 1.8)) (define (bmi wkg lm) (/ wkg lm lm)) "Convert -5 C to F" (ctof -5) "Convert 23 F to C" (ftoc 23) "BMI for body weight 85 kg, length 1.85 m = " (bmi 85 1.85) ))) It has made this JS which I have manually completed for console outs: jarmo$ cat funcs.js "use strict"; function ctof(cdeg){return (32+(1.8*cdeg));}; function ftoc(fdeg){return ((fdeg-32)/1.8);}; function bmi(wkg,lm){return (wkg/lm/lm);}; console.log("Convert", -5, "C to F", ctof(-5)); console.log("Convert", 23, "F to C", ftoc(23)); console.log("BMI for body weight 85 kg, length 1.85 m = ", (bmi(85,1.85).toFixed(2))); That was run within node: jarmo$ node funcs.js Convert -5 C to F 23 Convert 23 F to C -5 BMI for body weight 85 kg, length 1.85 m = 24.84


jjlammi
2021-3-14 22:16:04

@pihentagy (define (first a) (car a)) (define (second lista) (car (cdr lista))) (first '(1 2 3 4)) (second '(1 2 3 4)) (printf "This is not second:\n") (cdr '(1 2 3 4)) result: 1 2 This is not second: '(2 3 4) >


hazel
2021-3-14 22:20:58

so let’s say that I have a sequence that is 3 parallel values, and a sequence that is a single value. how can I turn this into a sequence with four parallel values?


soegaard2
2021-3-14 22:22:53

@hazel I think, you are looking for in-cycle


hazel
2021-3-14 22:23:14

no since I don’t want the resulting sequence to be infinite


hazel
2021-3-14 22:23:51

like if I have a sequence that’s (1 2 3) -> (4 5 6) -> (7 8 9) -> end, and a sequence that’s #f -> #f -> #f -> end then I want a sequence that’s (1 2 3 #f) -> (4 5 6 #f) -> (7 8 9 #f) -> end


hazel
2021-3-14 22:24:08

so kind of like in-parallel, but flattened


hazel
2021-3-14 22:28:34

> (sequence-for-each (lambda (x y) (printf "(~a ~a) " x y)) (in-parallel "hello" "slick")) (h s) (e l) (l i) (l c) (o k) so like this but with multiple elements in the first stream


raoul.schorer
2021-3-14 22:34:20

Hi, I have a module defining a datastructure that can be parametrized by two module-level variables (top level define). How do I make it possible to import several variants by name (i.e. differing only by the two top-level vars)? Can I use normal parameters and submodules, or do I need to generate submodules at compile-time with syntax parameters?


samth
2021-3-14 22:38:50

The goal is that what you would write in untyped Racket should work in Typed Racket too


samth
2021-3-14 22:40:22

This is the standard use case for units


samth
2021-3-14 22:40:46

However, you might also consider just using lambda


samth
2021-3-14 22:42:19

@hazel you should probably just write that combinator yourself


notjack
2021-3-14 22:56:19

@hazel Alternatively, consider grouping the values into structs, so you’d have a sequence of structs instead of a multi-value sequence. Then you can use sequence-map to combine the two sequences.


rokitna
2021-3-15 00:05:45

I believe there’s a library with an in-mapped operation which does something like sequence-map but in a way that gets inlined in a for loop.


rokitna
2021-3-15 00:06:53

It can’t be used outside of a for loop though, so it doesn’t take the place of sequence-map.