Skip to content

Some difficulties to keep track of #4

@aspiwack

Description

@aspiwack
  • In current GHC, constaint resolution is parallel, so that in

    f :: A =o X
    f = (methA, methA)

    both holes are solved independently (in fact, in this case, they are even the same hole!). But we really can't do that, because the use of the A dictionary in one precludes the use of the A dictionary in the other.

  • The constraint solver needs to be careful not to duplicate linear constraints (that is, it's not only an issue of constraint generation). e.g.

    instance (A, A) =o B
    
    f :: A =o X
    f = methB -- should fail!
  • We need to be able to typecheck all branches of a case/if with one occurrence of each linear constraint in each branch

    f :: A =o Bool -> X
    f b = if b then methA else methA -- ok!
    
    g :: A =o Bool -> X
    g b = if b then methA else noA -- should fail!
  • g :: RW s => Array s -o Int
    g arr = do
       .. -- RW s constraint here
       () <- writeArray 0 0 arr
       .. -- RW s constraint might be the same or different
       () <- writeArray 0 0 arr -- - which RW dictionary?
       Return 0
    -- problem: changing =o to => causes an ambiguity error
    -- in functions, changing ->. to -> doesn’t cause an error

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