Skip to content

Well formedness of Associated data type #33

@fxdpntthm

Description

@fxdpntthm

Currently we assign a mirror $wf:ATC to an associated type ATC of class say C.
or

class C  a where
   type ATC a 
   op :: ...

gets elaborated to

class C  a where
   type ATC a 
   type $wf:ATC a :: Constraint
   op :: ...

Will it be more appropriate to add the class constraint as the wellformedness mirror?

Possible problem may be that the associated data type has fewer type variables than the class variables potentially, giving rise to unambiguous types post elaboration.

Motivation:
There are cases where a data type references an associated type.

data IsNode a => Graph a = Graph { graphMap :: (Map (Key a) a) }

class Ord (Key a) => IsNode a where
  type Key a :: *
  nodeKey :: a -> Key a
  nodeNeighbors :: a -> [Key a]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Low PriorityThings that are good to have but not neededquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions