Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typed Racket cannot handle compose that use multiple values #1430

Open
OnorioCatenacci opened this issue Jan 21, 2025 · 2 comments
Open

Typed Racket cannot handle compose that use multiple values #1430

OnorioCatenacci opened this issue Jan 21, 2025 · 2 comments

Comments

@OnorioCatenacci
Copy link

What version of Racket are you using?
8.15

What program did you run?

#lang typed/racket

(require qi)


(: add-up (-> Number Number Number))
(define (add-up n m) (+ n m))

(: cube (-> Number Number))
(define (cube n) (* n n n))

(: flow-values (-> Number Number Number))
(define (flow-values n m) (~> (n m) (add-up _ _) cube))

What should have happened?
The code should have compiled without a problem. This code compiles correctly:

#lang typed/racket

(require qi)


(: add-up (-> Number Number Number))
(define (add-up n m) (+ n m))

(: cube (-> Number Number))
(define (cube n) (* n n n))

(: flow-values (-> Number Number Number))
(define (flow-values n m) (~> (n m) (add-up _ _)))

If you got an error message, please include it here.

3-unsaved-editor:18:0: Type Checker: Polymorphic function `compose' could not be applied to arguments:
Argument 1:
  Expected: (-> b c)
  Given:    (-> Number Number)
Argument 2:
  Expected: (-> a b)
  Given:    (-> Number Number Number)
 in: (define (flow-values n m) (~> (n m) (add-up _ _) cube))

Please include any other relevant details
On Ubuntu 24.04 and using DrRacket for testing. Also tested with racket -I typed/racket (8.15 [cs]) and got the same error message.

@sorawee sorawee transferred this issue from racket/racket Jan 21, 2025
@sorawee
Copy link
Contributor

sorawee commented Jan 21, 2025

Here's a more minimal program that demonstrates the issue:

#lang typed/racket

(: f (-> Number (Values Number Number)))
(define (f x)
  (values x x))

(: g (-> Number Number Number))
(define (g x y)
  (+ x y))

((compose g f) 5)

@sorawee sorawee changed the title Typed Racket Cannot Parse Qi Pipeline Correctly Typed Racket cannot handle compose that use multiple values Jan 21, 2025
@OnorioCatenacci
Copy link
Author

Thank you! I try to keep my examples minimal but I can't always figure out the smallest example that will demonstrate an issue. Thanks for adding that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants