summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chickadee/graphics/seagull.scm24
1 files changed, 15 insertions, 9 deletions
diff --git a/chickadee/graphics/seagull.scm b/chickadee/graphics/seagull.scm
index 6b8073d..dcddfb9 100644
--- a/chickadee/graphics/seagull.scm
+++ b/chickadee/graphics/seagull.scm
@@ -1956,6 +1956,17 @@
;; of non-quantified function type specifications, one for each unique
;; type of call in the program.
+;; Check if the substitutions in a and b do not contain
+;; contradictions.
+(define (consistent? a b)
+ (every (match-lambda
+ ((from . to)
+ (let ((other (assq-ref b from)))
+ (or (not other) (equal? to other)))))
+ a))
+
+;; Compute all the valid permutations of substitutions that a
+;; predicate could produce.
(define (possible-substitutions pred)
(match pred
(#t '())
@@ -1974,17 +1985,12 @@
(append-map (lambda (a)
(if (null? rest-options)
(list a)
- (map (lambda (b)
- (compose-substitutions a b))
- rest-options)))
+ (filter-map (lambda (b)
+ (and (consistent? a b)
+ (compose-substitutions a b)))
+ rest-options)))
options)))))))
-(define (possible-signatures type)
- (define type* (for-all-type-ref type))
- (map (lambda (subs)
- (apply-substitutions-to-type type* subs))
- (possible-substitutions (for-all-type-predicate type))))
-
(define (resolve-overloads program)
(match program
(('t types ('top-level bindings body))