private/effects.ss
(module effects mzscheme
  (require "big-unit.ss" "effect-structs.ss" (only (lib "unit.ss") provide-signature-elements)
           (lib "match.ss")
           (only "types.ss" make-value))
  (provide-signature-elements effect-structs^)
  (provide (all-defined))
           
  (define-struct tc-result (t thn els) #f)
           
  (define ret
    (case-lambda [(t) (make-tc-result t (list) (list))]
                 [(t thn els) (make-tc-result t thn els)]))
  
  (define (-vet id) (make-var-true-effect id))
  (define (-vef id) (make-var-false-effect id))
  
  (define -rem make-remove-effect)
  (define -rest make-restrict-effect)
  
  (define (var->type-eff eff)
    (match eff
      [($ var-true-effect v) (make-remove-effect (make-value #f) v)]
      [($ var-false-effect v) (make-restrict-effect (make-value #f) v)]
      [_ eff]))
  
  (define ((add-var v) eff)
    (match eff
      [($ latent-var-true-effect) (-vet v)]
      [($ latent-var-false-effect) (-vef v)]
      [($ latent-restrict-effect t) (make-restrict-effect t v)]
      [($ latent-remove-effect t) (make-remove-effect t v)]
      [($ true-effect) eff]
      [($ false-effect) eff]
      [_ (error 'internal-tc-error "can't add var to effect ~a" eff)]))
  
  )