
Hi all, can anyone help me to get this to run in typed racket? Welcome to DrRacket, version 7.7.0.4 [3m].
Language: typed/racket/base, with debugging; memory limit: 1024 MB.
> (require racket/match)
(match #hash((a . 3)(b . 4))
[(hash-table [a b][c d]) d])
;Type Checker: Polymorphic function `hash-map' could not be applied to arguments:
;Domains: HashTableTop (-> Any Any c)
; (HashTable a b) (-> a b c)
;Arguments: (Immutable-HashTable Symbol Integer) (All (a) (-> a * (Listof a)))
; in: (match #hash((a . 3) (b . 4)) ((hash-table (a b) (c d)) d))

@bedeke That reminds me - did we ever get your PR merged?

Which one? The ones about erf/gamma in the complex plane?

Yes.

It’s not, but I also asked some questions after the review that have not been answered yet, so I think it needs a little more polish before being ready

@jbclements What were you hinting about wrt the output types?

https://bdeket.synology.me/azjHOA4q9826/erftest.htm this is what I used it for

That looks great!

thanks

The hash-map
must be something that match
introduces, but I don’t know how to fix the problem.

What dependencies do I have to install to be able to compile rktio_convert.c
when building Racket from source so that using CoreFoundation/CFString.h
works on Mac?

clang
works but gcc
doesn’t? Sounds like you have an unhelpful gcc
in your path. You could either fix your system configuration to use gcc-as-clang or select clang
as the compiler with something like make CONFIGURE_ARGS_qq=CC=clang
.

@bedeke @soegaard2 that program is not going to typecheck in anything like that form — the expansion of hash-table
in match
is just too complicated.

Ok, thanks. Back to cond it is

I have a version of gcc
installed through a Nix package. Is that the problem?

you could use match
on the output of hash-map
, potentially

I think so. try make gcc
an alias to clang

I’ve removed the nix-profile bin from my PATH, and am trying again

I would try @mflatt’s suggestion before making gcc an alias for clang, because gcc isn’t clang.

oh neat. My real program has more nested hashes, but I think this could do the trick

clang has been pretending to be gcc on mac for a while

I’m assuming the way the Racket build uses gcc
is according to the common interface where clang
would work just fine. (Probably doesn’t use any features that gcc
has and clang
doesn’t) After removing the nix-profile bin directory from my path so that gcc
is back to Mac’s normal alias of clang
, building Racket from source seems to be working so far. It has gotten past the point it failed before.

Hi all, since a few version ago we have raco pkg install -D
but for older versions the trick was to raco pkg install --no-setup X && raco setup -D X
and I thought this would always work. It doesn’t. Not for collections-lib
for example. See https://github.com/pmatos/actions-test/runs/636559583?check_suite_focus=true#step:5:4 Does anyone know why?

raco setup
expects collection arguments, not packages. Use raco setup --pkgs
to specify packagess instead of collections.

ah! So what’s correct is raco pkg install --no-setup X && raco setup --pkgs -D X
?

I think --pkgs
needs to be after any other flags.

@mdssjc has joined the channel

Yep… thanks!

Has anyone ever seen this error message: ../../src/uceil_log2.c:40: MPFR assertion failed: exp < 1023
I assume it is an MPFR issue, and I’m told I’m the only one using the bigfloat
library, but just asking

@plragde Did you solve the width problem?

What’s the best way to check whether I’m currently running my program in DrRacket or on the command line? Currently I’m checking the output of (system "tty")
but there must be a better way I guess.

(on Unix)

Haven’t seen it - but I don’t use bigfloats that often.

In principle racket-cas supports bigfloats, but the bigfloat tests are scarce…

in racket-cas that is.

@laurent.orseau I think by design that it is meant to be hard to figure out, that the program is running in DrRacket.

Basically I need to know whether the current output supports colors

Ideally I’d have DrRacket know about ansi colors, but I don’t think that’s going to happen anytime soon

The tty trick doesn’t seem to work on macOS:

(in the terminal)

indeed. At least it works when running a program from the command line

(system "tput colors")
looks better. Can you confirm?

FWIW The Julia project has run into the same error, so maybe it is an MPFR problem.


And in DrRacket:

cool, thanks

Here’s the magic code: (let ([out (open-output-string)])
(define res
(parameterize ([current-output-port out]
[current-error-port (open-output-string)])
(system "tput colors")))
(string->number (string-normalize-spaces (get-output-string out))))

You could check if (port-writes-special? (current-output-port))
returns #f

Also not 100% probably

Does the repl in racket-mode support ansi colors?

I filed a bug in MPFR; it’s a known issue that will be released in 4.0.2 (eventually…) that specifically affects erf and erfc

Yes, thanks! It was a CSS issue with the embedded player, nothing to do with Racket at all. I should still learn how to vary some of the layout from scribble/manual defaults, but that can wait.

you can use ansi color control code at repl


Hmm. From a racket-mode repl in GUI emacs on macOS:

@laurent.orseau ^

Things that use comint-mode
in Emacs — like M-x shell, and the Racket Mode REPL — probably have in newer Emacs by default the ansi-color-process-output
function in the variable comint-output-filter-functions
. In other words, there is no “terminal” involved, simply an Emacs function that looks for ANSI color codes in the output text and arranges for those to be changed into color text properties in the buffer.

Of course Emacs also has M-x ansi-term, and in that tput colors
returns something like 8
for me.

For the Racket Mode REPL buffer, the comint-output-filter-functions
variable by default looks something like this: (racket-repl-display-images
ansi-color-process-output
comint-postoutput-scroll-to-bottom
comint-watch-for-password-prompt)
Which explains certain “magic” you may see.

But all of these except racket-repl-display-images
is just the standard comint-mode
stuff you’d also see in e.g. M-x shell and probably many other languages’ REPLs.

How can Laurent determine that the program is running inside a racket-mode repl?

Good question. In general, I’m oriented toward trying to make programs not know they’re running inside the Racket Mode REPL because that’s usually desirable. :smile:

I’m getting this error from raco
: Downloading repository <https://github.com/oflatt/egg-herbie.git#egg-herbie-deploy-linux>
11
git-checkout: no commit found matching id
I suspect this is because the egg-herbie
repository does not preserve history (or old commits); how do I get the package server to get the most recent commit ID?

You could look for the env var EMACS
, but that doesn’t narrow it down from e.g. ansi-term.

I could try to provide some “official” and stable way, to detect.

Not sure whether there is a better method, but sign in to http://pkgs.racket-lang.org\|pkgs.racket-lang.org and then choose “Rescan all my packages”.

(require racket/tcp) (tcp-port? (current-output-port))
is a clue but that’s a detail of the implementation today.

The alternative is of course to let the user configure the program whether to use ansi or not.

Automatic would be cool though.

I feel like “output ANSI color codes?” is the sort of thing where maybe it’s nice to try to auto-detect but … ah you typed just what I was going to type.

:slightly_smiling_face:

Great minds…

Yeah i have parameter that can be changed by the user but it’s annoying so I’m trying to do it as automatically as possible. –1 is actually ok since it’s still a number :D

Oh boy…

Doesnt it mean infinite? ;)

So with this using clang
, the build mostly worked, except for one thing, an error rendering the docs involving bytes-convert
and bytes-open-converter
: raco setup: running: <pkgs>/racket-doc/scribblings/reference/reference.scrbl
examples: exception raised in example
error: "bytes-convert: contract violation\n expected: bytes-converter?\n given: #f\n argument position: 1st\n other arguments...:\n #\"ABCD\""
This seems to be because bytes-open-converter
is returning false on the version I built from source: $ racket
Welcome to Racket v7.5.0.13.
> (bytes-open-converter "UTF-8" "UTF-16")
#<string-converter>
> ^D
$ ./racket/bin/racket
Welcome to Racket v7.7.0.4.
> (bytes-open-converter "UTF-8" "UTF-16")
#f
> ^D
The docs say it returns false if the requested conversion pair is not available. Why would it available in a snapshot version, but not a version built from source?

Another possibility is to use raco pkg install —clone

@santoshthapa.wk has joined the channel