
Weird, that’s doesn’t happen to me. What install type did you choose? I always install as a Unix distribution, even for snapshots where it’s not the default.

Our maybe that’s a recent issue? (The original post was from May)

Scheme 2021 - Graphite: A Library for Data Visualization (Lightning Talk) https://www.youtube.com/watch?v=qSM-rbOkmn0\|https://www.youtube.com/watch?v=qSM-rbOkmn0

@soegaard2 Ah, I got it. That is what I wanted! Thank you! @sorawee It looks very customizable. I’ll try it :slightly_smiling_face:

I didn’t make myself clear. This issue has nothing to do with using installers from the download page. It only happens if users install racket through the suse’s official package manager (zypper or yast)

The package website seems weirdly broken. https://pkgs.racket-lang.org/package/pprint-compact and https://pkgs.racket-lang.org/package/fmt are both built — you can see the documentation at https://docs.racket-lang.org/pprint-compact/ and https://docs.racket-lang.org/fmt/. Yet, they are reported as no doc and no recent builds.

Is there a polymorphism mechanism (ideally typeclasses) for typed racket? What is the right way of dealing with overloading?

Also, is typed/racket generally faster than racket or does it do typechecks at runtime?


Typechecking is done at compile-time. So the compile-time will be slower compared to vanilla Racket, but run-time could be faster, due to Typed Racket optimization.

Hmm, what I had in mind was for racket to select an the implementation of a function:
;; A type that implements the class Show can be converted to string.
(typeclass (Show type)
(: show (-> type String)))
;; Showing a number is done using number->string
(instance (Show Number)
(define-method (show num)
(number->string num)))
;; Showing a string is just returning the string
(instance (Show String)
(define-method (show str) str))

excellent, thank you

There’s one caveat: if you have an interaction between typed and untyped modules, Typed Racket needs to insert contracts at the boundary, and this could be expensive. But if the entire thing is in Typed Racket, the performance should be better than vanilla Racket.

I found something similar called case-lambda
but it only selects between arities

That’s fair

I’d caution against trying to write Haskell code in Racket; if you want Haskell use Haskell :wink:

there was a discussion of generics for typed racket recently

and they are not supported (yet)


ok then

is there an any
function that finds at least one element of a list satisfying a predicate function like (any odd? '(1 2 3)) => #t
?

like vector-any
but for lists

got it, I was missing (require srfi/1)

I use for/or
and for/and
for generic sequences:
(define (all? xs)
(for/and ([x xs]) x))
(define (any? xs)
(for/or ([x xs]) x))

obviously replace x
with (predicate x)
if needed

ormap
?

typed racket is missing srfi1?

@tbnelson has joined the channel

No, findf
is the one you ned.

nope ; use (require srfi/1)


hmm, that sucks.. I have been thrice today against calling untyped code from typed racket

nb racket has a distinct facilities for sets https://docs.racket-lang.org/reference/sets.html

(I just noticed sets are part of srfi 1)

TR doesn’t have types for in-cycle
and for the stream library.
I think in-cycle
would be easy to add to the base environment (typed-racket-lib/typed-racket/base-env/base-env.rkt
). Streams are harder to support, but the typed-racket-stream
package is a nice work-around.
Here are two things that work for now: ;; in-slice
(require/typed racket/sequence
(in-slice (All (A) (-> Natural (Sequenceof A) (Sequenceof (Listof A))))))
(~> (in-cycle '(A B))
(in-slice 9 _)
(sequence-ref _ 0))
;; stream
(require typed/racket/stream)
(require/typed racket/base
(sequence->stream (All (A) (-> (Sequenceof A) (Sequenceof A)))))
(~> '(A B)
in-cycle
sequence->stream
(stream-take 9)
stream->list)

@cperivol see andmap
and ormap

which are the built-in versions, rather than the ones from srfi/1

how can I pattern match on Option
? (match (ann 1 (Option Integer) [#f 0] [n n])
complauins about the type of n
.

And unions in general

cond
will work, but the current implementation of match
is too expressive that n
is not guaranteed to be non-#f

For example, the following match
program will fallback to the n
clause: (match (ann #f (Option Integer)
[#f (=> fail) (fail)]
[n n])

that worked nicely

Quite interesting how it makes those inferences, is there a paper on that?




this is fantastic!