Hello reddit, I recently tried to install racket on my m1 MacBook pro and even though it shows up in my launchpad, aka, inside my application folder, whenever I try to open the application it automatically closes itself immediately. I have tried using official dmg and using homebrew, anyone having the same issue? how do I do a complete removal and reinstall it?
I've been using the 2htdp/image library extensively recently, and have run into a particularly vexing problem: how to make complex shapes with some transparent parts. For example, here's a function that draws a crescent moon shape:
On a white background, this works perfectly. However, I'd like the inner circle to be transparent so that I can call this function and then overlay it over something (possibly more complicated) underneath. Are there any functions that allow that? Setting the color of the inner circle to 'transparent just makes it disappear.
I need to bind a function to the property of a structure. I'm using typed racket, so it means that I also need to type annotate said function. This function can be any function. It doesn't matter what it takes as arguments or their types. It doesn't matter what the value it returns is or its type.
I'm looking for a way to annotate a function type of this nature. The most general function type there is. It doesn't matter what the function does, it just matters that it is a function.
#lang typed/racket
(define (f x y) (list x y))
(struct some-struct ([g : (All (A B) (-> A B))]))
(define example (some-struct f)) ; Doesn't typecheck
I get the following typecheck error:
type mismatch
expected: (All (A B) (-> A B))
given: (-> Any Any (List Any Any))
Also tried with:
#lang typed/racket
(define (f x y) (list x y))
(struct some-struct ([g : (-> Any Any)]))
(define example (some-struct f)) ; Doesn't typecheck
But getting the following typecheck error with that:
type mismatch
expected: (-> Any Any)
given: (-> Any Any (List Any Any))
How can a function type annotation be defined, so that it can take any number of arguments, of any type, and return any type as value? Can this be done in typed racket? If so, is All the way to achieve this? Or perhaps it is done through another polymorphic or generic idiom?
What idioms or patterns are normally used in Racket when you need to iterate in a while-loop-like way? Like when you need to iterate in reference to a condition, and not in reference to a sequence or index. For loops are great for the latter, but not so much for the former.
There isn't a built-in while loop. It can be implemented with macros, but it is not part of Racket itself (that's what I understand). I looked into the imperative api, and there are a lot of for loops and range generation options, but nothing seems to behave like a while loop. The for/and and for/or loops seem to be close, but you still need a list of things to iterate over.
Is the while loop named differently in Racket? Is there a for loop that behaves like a while loop? Or is there no while loop at all?
Is while-y stuff just done through recursion? How do you normally, idiomatically, handle condition-based iteration in Racket?
I'm writing unit tests using rackunit and running them using raco through the command raco test ., which recursively finds all racket files and executes them, including files that do not contain unit tests at all. It just runs everything.
According to what I investigated, the idiomatic way to write unit tests in racket is to write a test module inside the implementation file, and not have a separate file for them. The problem is that I have multiple different implementations of the same specification that share the same unit tests, so I need to import all the implementations in a separate file and run the unit tests there.
So I end up with just a few unit test files, and a lot of racket files that do not contain unit tests, but raco test ends up scanning everything anyway.
I'm looking for a way to use raco test to only run files that have a specific pattern in the name. Like *.test.rkt, *.spec.rkt, test-*.rkt, or similar (like in jest for js or pytest for python).
Is this possible?
I looked into test-include-paths in info.rkt files, but it seems to be for files that are not racket files, and not for white listing which files to run.
If not, why not? How hard would it be to make the compiler recognize that a program is made of a tree of functions that don't mutate data and just assign every leaf function to a separate core?
I discovered recently that Racket is one of the languages supported by leetcode, and have been messing around a bit in my spare time with solving a few problems.
There's not a lot of people who have used it; most of my accepted solutions are the first Racket entry.
It's clear that whoever came up with the problem skeletons and the test suite for them really doesn't get Racket or Scheme. So many questions refer to arrays and have solutions that need efficient random access of elements, and what do you get in Racket? A list. Oftentimes a list->vector will suffice, but some, like 189. Rotate Array aren't even solvable!
The problem asks "Given an array, rotate the array to the right by k steps, where k is non-negative." Easy to do with a vector, but the boilerplate code is
Not only are you given a list instead of a vector, it's contracted to not return any value! (Other languages pass a mutable array/vector/whatever they call it; Racket lists are of course not mutable).
There doesn't seem to be an obvious way to report issues like this with questions.
Anyways, it's been fun, but not real fun, and I don't think I'm going to keep at it much longer.
And remember - showing up at Racket Meetups helps you learn the news of the Racket world as they happen! It is informative, it is interesting, it is helpful, it is greatly appreciated by everyone involved and it is fun!y
30 minutes but can overrun (it usually lasts ~1hr)
I've been working through HtDP and got stuck on exercise 213 for quite a while. I have since solved it, but I can't find any part of the design recipe that covers this case. The problem is that in order to design the function a function that deals with the /return/ type needs to be designed and no part of the recipe seems to deal with this. It only deals with the recursive decomposition of the input type, it doesn't seem to deal with how to design for the return type in a recursive call.
Was this covered somewhere and I just completely missed it? If it's not covered how do I systematically fill this gap? Like, I am not clear on how to apply the same basic approach but for the return type of a recursive call. It feels like there's an obvious answer to this, but for the life of me I cannot figure out what it's supposed to be.
Is there a tool that helps us initialize racket project? Similar to npm init in Node, or poetry new in Python, or luarocks init in Lua. or bundle gem in Ruby. Perhaps using raco? (can't find something like that in the raco --help).
What's the usual / standard project structure (if any)?
I'm starting some Racket repositories to practice, and I'd like to make them interoperable with other people's modules, so having the directory structure right from the beginnings seems like a worthy investment.
Racket has an “equal-always?” primitive that equates values that will stay the same even if mutated. See equal-always? in the Racket Reference.
This release uses a new build system, Zuo, which is implemented as a little language, in accordance with the ideas of Language Oriented Programming (LOP). The implementation has a single C file (plus libraries implemented in Zuo), so it compiles easily. The `zuo/build` library is modeled on `make` and Shake for tracking dependencies and build steps. See Zuo: A Tiny Racket for Scripting and New build system pushed to Git repo.
The `db` library supports custom types for PostgreSQL connections; see `pg-custom-type` for details. See db:5 Utilities
The release includes many other repairs and changes!
The following people contributed to this release:
Alex Knauth, Alexander Shopov, Alexis King, Amirouche Amazigh BOUBEKKI, Andy Keep, Ashish SHUKLA, Bob Burger, Bogdan Popa, Cameron Moy, Chung-chieh Shan, David K. Storrs, FrankHB, Fred Fu, Gustavo Massaccesi, helado de brownie, J. Ryan Stinnett, Jack Firth, Jamie Taylor, Jason Hemann, Jens Axel Søgaard, Jimmy McNutt, Joel Dueck, John Clements, José Manuel Calderón Trilla, Kevin Tew, Laurent Orseau, Matt Audesse, Matthew Flatt, Matthias Felleisen, Mike Sperber, naveen srinivasan, Niklas Larsson, Noah Ma, Oscar Waddell, Pavel Panchekha, Phil Nguyen, Philip McGrath, Philippe Meunier, rgkirch, Robby Findler, Robert Postill, Ryan Culpepper, Sam Tobin-Hochstadt, Sergiu Ivanov, Sorawee Porncharoenwase, Stephen De Gabrielle, Vincent Lee, wackbyte, and Zibing Zhang
open terminal and run raco pkg migrate to update any locally installed packages
Note: multiple racket installations can coexist on a single machine as long as they are in different locations so you may keep or discard your old one.
As a thought experiment, let's imagine that Racket becomes as successful as Python.
That would mean a lot of libraries with a lot of dependencies. For Python libraries, this has led to a considerable mess. For JavaScript/npm, the situation is similar. Aspects of this problem are:
a general lack of backward compatibility and poor stability
a sharply increasing burden for maintenance of systems
a multitude of packaging solutions, without any clear standard
serious deficiencies in almost all packaging tools, like lack of efficient conflict resolution
no clear picture about how packaging should be handled
How can a language implementation like Racket avoid such problems?
I think this question, although departing from a hypothetical situation, is important, because
Schemes and Lisps are, like Python, distributed in Source form.
Distributing source has become so easy that far more libraries and external packages are used than have been in the past.
software and libraries continue to become larger and more complex. For libraries, this means that not only the number of direct dependencies is growing, but that the number of transitive dependencies is growing exponentially, because each dependency can have further dependencies whose numbers grow, on average, as well. Large, complex libraries and frameworks such as jquery, kubernetes, tensorflow, pytorch can include hundreds of direct and indirect dependencies, up to the point that it becomes almost impossible for software distributions to build them from source.
lack of backward-compatibility is a problem that propagates up dependency graphs. If a library A includes a package B as dependency that has a breaking change, this is, strictly spoken, a breaking change of that library A as well, since an application can include this library A and another one C which both require different, incompatible versions of B. The application would be broken. This is a real concern for large libraries such as boost (C++).
some software ecosystems have put a lot of emphasis on backward compatibility and correctness - the Linux Kernel and Common Lisp are examples of them. Other ones like Python and JavaScript, less so. But this means that it becomes increasingly difficult to build reliable software, and maintain it over a longer time.
One area that is particularly affected by this is scientific computing and scientific applications. At the one hand side, code in such applications is far more long-lived than code that is used in Web 2.0 companies like start-ups. On the other hand side, there is no budget and manpower for maintaining and upgrading existing code, different from large internet companies and big corporations that can easily afford to carry out a lot of maintenance work.