laurent.orseau
2022-5-15 13:06:35

Strange. Can’t do much about it this weekend, but I’ll take a look soon. Although I have no good idea about what’s happening. Maybe a race condition—I don’t understand the behaviours of the underlying tools well enough I must admit.


ben.knoble
2022-5-15 16:57:17

It does seem like an obvious and compact way to represent all the information you need for the prefab type in the presence of struct inheritance? Esp. since #s(a 1) and #s(a 1 2) are already completely different types (and you don’t have to declare them to be able to read and manipulate them, AFAIK). So how would you know from just #s(s3 1 2 3 5 6 7) that s3 was a structure type of that kind of inheritance chain? The way that reads currently is a completely different type with 6 uninherited fields.


ricky.y.c
2022-5-15 17:25:03

A beginner’s question: is it possible to use pipelining in racket ? I’ve heard that we have curry in racket so I think pipeline in racket is possible In F# (not sure in Ocaml) or shell , we’ve got [1; 2; 3] \|> List.map add1 \|> List.filter even \|> List.reduce (+) or ls \| cat I think it is possible to use this syntax sugar in racket , such as ;; pipe is a function here in this example (pipe '(1 2 3) (curry map add1) (curry filter even?) (curry foldl + 0) ;; more curried function ... ) instead of (foldl proc init (filter predicate (map add1 '(1 2 3)))) In this case, my pipe function is: #lang racket (provide (all-defined-out)) (define (pipe value . arg*) (define (pipeline value proclist) (if (empty? proclist) value (pipeline ((car proclist) value) (cdr proclist)))) (pipeline value arg*)) this seems not good enough since we handled everything at runtime instead of compile-time. Is here a better solution? :-)


soegaard2
2022-5-15 17:25:33

Lookup threading and qi.


soegaard2
2022-5-15 17:26:34

There is a presentation on QI here: https://www.youtube.com/watch?v=XkIoGmWkEpM


soegaard2
2022-5-15 17:27:23

The docs for threading lives here: https://docs.racket-lang.org/threading/index.html


ricky.y.c
2022-5-15 17:27:37

Advanced!


soegaard2
2022-5-15 17:28:10

Qi - yes. Threading is (I think) what you asked for :slightly_smiling_face:


ricky.y.c
2022-5-15 17:29:47

“Threading” in racket sounds like a term in operating system. lol


soegaard2
2022-5-15 17:30:43

True! In this case the name came from Clojure.


greg
2022-5-15 17:31:19

Your pipe example using one of the threading macros would be IIUC: (require threading) (~>> '(1 2 3) (map add1) (filter even?) (foldl + 0))


greg
2022-5-15 17:33:10

That macro expands at compile-time to: (foldl + 0 (filter even? (map add1 '(1 2 3))))


soegaard2
2022-5-15 17:33:35

Btw - the name “pipe” is also a term from operating systems.


ricky.y.c
2022-5-15 17:34:06

oops, that’s true.


ricky.y.c
2022-5-15 17:38:07

So there’s no curried functions but macros. Cool!


greg
2022-5-15 17:42:30

Right, if you don’t apply all required arguments to a function, in Racket, that’s an error. It doesn’t automatically result in a new function that accepts the remaining arguments, as in Haskell or (sorry for my ignorance, I’m assuming) F#.


greg
2022-5-15 17:44:27

It’s a trade-off. In Racket you can define a function that accepts any number of arguments. That can be very useful (look at map, for example, which accepts an arbitrary number of lists) but it means you can’t “auto curry”.


greg
2022-5-15 17:45:12

Having said that, you can in Racket define your own #lang to do just about anything, including redefine application via #%app to act however you want. :slightly_smiling_face:


ricky.y.c
2022-5-15 17:47:43

I haven’t understood this stuff yet — #lang and Macro. Seems pretty complicated.


jung.ry
2022-5-15 21:42:48

@jung.ry has joined the channel


wjb
2022-5-15 22:33:39

Oh it’s because read actually has to create the struct if it doesn’t exist. gotcha