Skip to content

Nesting Functional Dependencies Requires Extraneous Type Variable #1716

@Jason94

Description

@Jason94

It should be possible to define a class hierarchy like this:

(coalton-toplevel

  (define-class (HasA :t :a (:t -> :a))
    (get-a (Proxy :t -> :a)))

  (define-class (HasA :t :a => WrapsHasA :w :t (:w -> :t))
    (get-two-as (:w -> Tuple :a :a)))
  )

Because, in the definition of WrapsHasA, :a can be determined by :t, that should be fully defined. Instead, Coalton forces WrapsHasA to also declare the inner type variable. Trying to compile the above gives this error:

      error: Unknown type variable
      --> test.lisp:6:25
       |
     6 |    (define-class (HasA :t :a => WrapsHasA :w :t (:w -> :t))
       |                           ^^ Unknown type variable :A

and the only fix is to also encode :a in WrapsHasA, like this:

(coalton-toplevel

  (define-class (HasA :t :a (:t -> :a))
    (get-a (Proxy :t -> :a)))

  (define-class (HasA :t :a => WrapsHasA :w :t :a (:w -> :t))
    (get-two-as (:w -> Tuple :a :a)))

  )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions