[racket] how to improve performance by streamlining imports?
On Feb 21, 2014, at 2:38 PM, Matthew Butterick wrote:
>> Rewriting to avoid a dependency does work, but usually only if you can
>> avoid some large subsystem (such as the contract system) completely.
>
>
> Contracts are a good example. Here's the vexing pattern that I've run into frequently
Perhaps you want to organize your programs in something like this fashion:
#lang racket
(module server racket
(provide
(contract-out
(f (natural-number/c . -> . natural-number/c))))
(module fast-server racket
(provide
;; Nat -> Nat
f)
(define (f i)
(- i 1)))
(require (submod "." fast-server)))
(module safe-client racket
(require (submod ".." server))
(with-handlers ((exn:fail:contract? (compose displayln exn-message)))
(displayln (f 0))))
(module fast-client racket
(require (submod ".." server fast-server))
(displayln (f 0)))
(require 'safe-client)
(require 'fast-client)