coalton-lang/coalton

Ambiguous method error in class definition when method doesn't include both parameterized types

Izaakwltn opened this issue · 0 comments

When defining a class with multiple parameterized types, each method must employ both types.:

(coalton-toplevel

  (define-class (C :a :b)
    (m1 :a)
    (m2 (:a -> :b))))

Compiling returns:

  error: 
    (during macroexpansion of (COALTON-TOPLEVEL
      (DEFINE-CLASS #
        ...)))
    error: Ambiguous method
      --> <macroexpansion>:3:4
       |
     3 |      (M1 :A)
       |      ^^^^^^^ the method is ambiguous

This also errors:

(define-class (C :a :b)
    (m1 (Unit -> :a))
    (m2 (:a -> :b)))

This may be just a Hindley-Milner rule that I'm not yet privy to.