You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Welcome to Racket v8.14 [cs].
> (let#:∀ (a ...) ([thk : (→ (Values a ... a)) (λ () (values 123))])
(thk))
- : (values Integer Integer Integer) [more precisely: (Values One Positive-Byte Positive-Byte)]
123
> (let#:∀ (a ...) ([thk : (→ (Values a ... a)) (λ () (values 123))]) : (Values a ... a)
(thk))
string:1:80: Type Checker: Error in macro expansion -- parse error in type;
type variable must be used with ...
variable: a
in: a
[,bt for context]
Equivalent code that works by wrapping Values inside a function type:
> (: f (∀ (a ...) (→ (→ (Values a ... a)) (Values a ... a))))
> (define (f thk) (thk))
> (f (λ () (values 123)))
- : (values Integer Integer Integer) [more precisely: (Values One Positive-Byte Positive-Byte)]
123
> (: g (∀ (a ...) (→ (→ (Values a ... a)) (Values a ... a))))
> (define (g thk1)
(: thk2 (→ (Values a ... a)))
(define thk2 thk1)
(thk2))
> (g (λ () (values 123)))
- : (values Integer Integer Integer) [more precisely: (Values One Positive-Byte Positive-Byte)]
123
Using Values in let/cc:
Welcome to Racket v8.14 [cs].
> (require typed/racket/unsafe)
> (unsafe-require/typed racket/base
[call-in-continuation
(∀ (a ...)
(case→ (→ (→ a ... a Nothing) (→ (Values a ... a)) Nothing)
(→ (→ Any * Nothing) (→ AnyValues) Nothing)))])
> (: h (∀ (a ...) (→ (→ (Values a ... a)) (Values a ... a))))
> (define (h thk)
(let/cc k : (Values a ... a)
(call-in-continuation k thk)))
string:2:2: Type Checker: Polymorphic function `call/cc' could not be applied to arguments:
Types: (-> (-> Nothing) (values)) -> (values)
(-> (-> Nothing) (values)) Prompt-TagTop -> (values)
(-> (-> a c ... c Nothing) (values b c ... c)) -> (values (U a b) c ... c)
(-> (-> a c ... c Nothing) (values b c ... c)) Prompt-TagTop -> (values (U a b) c ... c)
Arguments: (-> (-> a ... a Nothing) Nothing)
Expected result: (values)
in: (let/cc k : (Values a ... a) (call-in-continuation k thk))
[,bt for context]
A working alternative:
> (: i (∀ (a ...) (→ (→ (Values a ... a)) (→ (→ a ... a Nothing) (Values a ... a)))))
> (define ((i thk) k) (call-in-continuation k thk))
> (call/cc (i (λ () (values 123))))
- : (values Integer Integer Integer) [more precisely: (Values One Positive-Byte Positive-Byte)]
123
The text was updated successfully, but these errors were encountered:
What version of Racket are you using?
8.14 [cs]
What program did you run?
Values
in the return type oflet
:Equivalent code that works by wrapping
Values
inside a function type:Values
inlet/cc
:A working alternative:
The text was updated successfully, but these errors were encountered: