Greetings.

I have come across another occasion where TR appears to behave in an unexpected 
way.

Consider:

%  cat add1.rkt
#lang typed/racket/base

(provide add1)

(: add1 (-> Integer Integer))
(define (add1 x)
  (+ x 1))
% cat call-add1.rkt
#lang typed/racket/base

(require "add1.rkt")

(module+ main
  ;(require "add1.rkt")
  (printf "2 + 1 = ~a~%" (add1 2)))
% racket call-add1.rkt 
add1.rkt:3:9: Type Checker: missing type for identifier;
 consider using `require/typed' to import it
  identifier: add1
  from module: add1.rkt
  in: add1
  context...:
   
/Data/LocalApplications/Racket/6.1.1/share/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:275:0:
 type-check
   
/Data/LocalApplications/Racket/6.1.1/share/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:411:0:
 tc-module
   
/Data/LocalApplications/Racket/6.1.1/share/pkgs/typed-racket-lib/typed-racket/tc-setup.rkt:40:0:
 tc-setup
   
/Data/LocalApplications/Racket/6.1.1/share/pkgs/typed-racket-lib/typed-racket/typed-racket.rkt:25:4
   standard-module-name-resolver
%  racket --version              
Welcome to Racket v6.1.1.
%

It appears that the add1 is visible within the main module, but its type isn't. 
 Adding the (require) inside the module produces the same error.  Adding the 
(require) inside the module and removing it from the enclosing module does work 
in this example, but obviously makes add1 invisible in that enclosing module.

The TR documentation for #%module-begin 
<http://docs.racket-lang.org/ts-reference/special-forms.html?q=module-begin#%28form._%28%28lib._typed-racket%2Ftyped-racket..rkt%29._~23~25module-begin%29%29>
 says

> Otherwise, the #%module-begin form of typed/racket behaves like 
> #%module-begin from racket.

I take that to suggest that there should be no surprises here.  Looking through 
the TR reference, the only other mention I can see of modules is in Sect. 5.1 
on 'Untyped Utilities'.  I can't see any notes on this in the TR Guide Sect. 8, 
'Caveats and Limitations'.

As an additional remark (and this is a little weird), if I give in, and try to 
use require/typed, then I get a rather perplexing error:

% cat call-add1.rkt
#lang typed/racket/base

(require "add1.rkt")

(module+ main
  (require/typed "add1.rkt" [add1 (-> Integer Integer)])
  (printf "5 + 1 = ~a~%" (add1 5)))
% racket call-add1.rkt          
add12: unbound identifier;
 also, no #%top syntax transformer is bound
  in: add12
  context...:
   
/Data/LocalApplications/Racket/6.1.1/share/pkgs/typed-racket-lib/typed-racket/utils/require-contract.rkt:13:0
   
/Data/LocalApplications/Racket/6.1.1/share/pkgs/typed-racket-lib/typed-racket/tc-setup.rkt:40:0:
 tc-setup
   
/Data/LocalApplications/Racket/6.1.1/share/pkgs/typed-racket-lib/typed-racket/typed-racket.rkt:25:4
   standard-module-name-resolver
%

Best wishes,

Norman


-- 
Norman Gray  :  http://nxg.me.uk
SUPA School of Physics and Astronomy, University of Glasgow, UK

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to