Discussion:
[racket] typed racket: how to define a binding as both a runtime var and a type?
Alexander D. Knauth
2015-02-22 19:43:02 UTC
Permalink
Using #:omit-define-syntaxes doesn’t work because then when other modules import it it forgets about the type:

def.rkt:
#lang typed/racket
(provide x)
(define-type x 'x #:omit-define-syntaxes)
(define x : x 'x)

ref.rkt:
#lang typed/racket
(require "def.rkt")
x ; works fine, outputs 'x
(define y : x x) ; Type Checker: parse error in type; type name `x' is unbound in: x

Why doesn’t this work, and is there another way to do this?



____________________
Racket Users list:
http://lists.racket-lang.org/users
Matthias Felleisen
2015-02-22 20:01:26 UTC
Permalink
Why do you want that? It's confusing to write x : x. I'd prefer x : X anyways.
Post by Alexander D. Knauth
#lang typed/racket
(provide x)
(define-type x 'x #:omit-define-syntaxes)
(define x : x 'x)
#lang typed/racket
(require "def.rkt")
x ; works fine, outputs 'x
(define y : x x) ; Type Checker: parse error in type; type name `x' is unbound in: x
Why doesn’t this work, and is there another way to do this?
____________________
http://lists.racket-lang.org/users
____________________
Racket Users list:
http://lists.racket-lang.org/users
Alexander D. Knauth
2015-02-23 00:47:27 UTC
Permalink
Normally I would do that and capitalize the first character of the type, but I am trying to define values and types for the chemical elements, and those are capitalized already.
Post by Matthias Felleisen
Why do you want that? It's confusing to write x : x. I'd prefer x : X anyways.
Post by Alexander D. Knauth
#lang typed/racket
(provide x)
(define-type x 'x #:omit-define-syntaxes)
(define x : x 'x)
#lang typed/racket
(require "def.rkt")
x ; works fine, outputs 'x
(define y : x x) ; Type Checker: parse error in type; type name `x' is unbound in: x
Why doesn’t this work, and is there another way to do this?
____________________
http://lists.racket-lang.org/users
____________________
Racket Users list:
http://lists.racket-lang.org/users
Sam Tobin-Hochstadt
2015-02-22 20:12:43 UTC
Permalink
This looks like a bug to me.

Sam
Using #:omit-define-syntaxes doesn’t work because then when other modules
#lang typed/racket
(provide x)
(define-type x 'x #:omit-define-syntaxes)
(define x : x 'x)
#lang typed/racket
(require "def.rkt")
x ; works fine, outputs 'x
(define y : x x) ; Type Checker: parse error in type; type name `x' is unbound in: x
Why doesn’t this work, and is there another way to do this?
____________________
http://lists.racket-lang.org/users
Alexander D. Knauth
2015-02-23 00:54:23 UTC
Permalink
Could this have anything to do with it?

http://docs.racket-lang.org/reference/eval-model.html#%28part._separate-compilation%29
Post by Sam Tobin-Hochstadt
This looks like a bug to me.
Sam
#lang typed/racket
(provide x)
(define-type x 'x #:omit-define-syntaxes)
(define x : x 'x)
#lang typed/racket
(require "def.rkt")
x ; works fine, outputs 'x
(define y : x x) ; Type Checker: parse error in type; type name `x' is unbound in: x
Why doesn’t this work, and is there another way to do this?
____________________
http://lists.racket-lang.org/users
Sam Tobin-Hochstadt
2015-03-06 17:16:29 UTC
Permalink
Indeed, this was a bug introduced by the levels of indirection I added to
put contracts into submodules. I'll push a fix when the tests finish.

Thanks for finding this.

Sam
Post by Sam Tobin-Hochstadt
This looks like a bug to me.
Sam
Using #:omit-define-syntaxes doesn’t work because then when other modules
#lang typed/racket
(provide x)
(define-type x 'x #:omit-define-syntaxes)
(define x : x 'x)
#lang typed/racket
(require "def.rkt")
x ; works fine, outputs 'x
(define y : x x) ; Type Checker: parse error in type; type name `x' is unbound in: x
Why doesn’t this work, and is there another way to do this?
____________________
http://lists.racket-lang.org/users
Loading...