[racket] typed racket: another snippet of code that types a bit slowly

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Wed May 11 14:42:40 EDT 2011

I'm running into some code in my project that typechecks very slowly.
I've been able to isolate it to an area similar to what we hit across
earlier.  Below should be a reduced test case to show what I'm seeing.
 If the clauses are re-ordered so that the last one is moved up to the
first, then type checking seems to go a lot faster.  Dunno why yet.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang typed/racket/base

(require racket/list)

(define-type PrimitiveCommand (U
                               CheckToplevelBound!
                               CheckClosureArity!
                               CheckPrimitiveArity!
                               ExtendEnvironment/Prefix!
                               InstallClosureValues!
                               FixClosureShellMap!
                               InstallContinuationMarkEntry!
                               SetFrameCallee!
                               SpliceListIntoStack!
                               UnspliceRestFromStack!
                               RaiseContextExpectedValuesError!
                               RaiseArityMismatchError!
			       RaiseOperatorApplicationError!
                               RestoreEnvironment!
                               RestoreControl!
                               InstallModuleEntry!))

(define-struct: CheckToplevelBound! () #:transparent)
(define-struct: CheckClosureArity! () #:transparent)
(define-struct: CheckPrimitiveArity! () #:transparent)
(define-struct: ExtendEnvironment/Prefix! () #:transparent)
(define-struct: InstallClosureValues! () #:transparent)
(define-struct: SetFrameCallee! () #:transparent)
(define-struct: SpliceListIntoStack! () #:transparent)
(define-struct: UnspliceRestFromStack! ()  #:transparent)
(define-struct: FixClosureShellMap! () #:transparent)
(define-struct: RaiseContextExpectedValuesError! () #:transparent)
(define-struct: RaiseArityMismatchError! ()  #:transparent)
(define-struct: RaiseOperatorApplicationError! () #:transparent)
(define-struct: RestoreControl! () #:transparent)
(define-struct: RestoreEnvironment! () #:transparent)
(define-struct: InstallContinuationMarkEntry! () #:transparent)
(define-struct: InstallModuleEntry! ([entry-point : Symbol])  #:transparent)


(: collect-primitive-command (PrimitiveCommand -> (Listof Symbol)))
(define (collect-primitive-command op)
  (cond
   [(CheckToplevelBound!? op)
    empty]
   [(CheckClosureArity!? op)
    empty]
   [(CheckPrimitiveArity!? op)
    empty]
   [(ExtendEnvironment/Prefix!? op)
    empty]
   [(InstallClosureValues!? op)
    empty]
   [(RestoreEnvironment!? op)
    empty]
   [(RestoreControl!? op)
    empty]
   [(SetFrameCallee!? op)
    empty]
   [(SpliceListIntoStack!? op)
    empty]
   [(UnspliceRestFromStack!? op)
    empty]
   [(FixClosureShellMap!? op)
    empty]
   [(InstallContinuationMarkEntry!? op)
    empty]
   [(RaiseContextExpectedValuesError!? op)
    empty]
   [(RaiseArityMismatchError!? op)
    empty]
   [(RaiseOperatorApplicationError!? op)
    empty]
   [(InstallModuleEntry!? op)
    (list (InstallModuleEntry!-entry-point op))]))


Posted on the users mailing list.