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.
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.
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? :-)
Lookup threading and qi.
There is a presentation on QI here: https://www.youtube.com/watch?v=XkIoGmWkEpM
The docs for threading lives here: https://docs.racket-lang.org/threading/index.html
Advanced!
Qi - yes. Threading is (I think) what you asked for :slightly_smiling_face:
“Threading” in racket sounds like a term in operating system. lol
True! In this case the name came from Clojure.
Your pipe example using one of the threading macros would be IIUC: (require threading)
(~>> '(1 2 3)
(map add1)
(filter even?)
(foldl + 0))
That macro expands at compile-time to: (foldl + 0
(filter even?
(map add1
'(1 2 3))))
Btw - the name “pipe” is also a term from operating systems.
oops, that’s true.
So there’s no curried functions but macros. Cool!
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#.
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”.
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:
I haven’t understood this stuff yet — #lang and Macro. Seems pretty complicated.
@jung.ry has joined the channel
Oh it’s because read actually has to create the struct if it doesn’t exist. gotcha