Should (~) be homogeneous or heterogeneous?

MichaƂ J. Gajda mjgajda at gmail.com
Mon Nov 23 15:09:56 UTC 2015


Naive question:
Would it be "evil" or otherwise complicated to assume that (~) is
heterogeneous only in the _presence_ of kind constraint? Or only when
the kind can be inferred?
--
  Cheers
    Michal

On 23/11/2015 03:00, Richard Eisenberg wrote:
> 
> * Should (~), as written in user code, require the kinds of its arguments to be equal?
> We can see that the kind of the type variable kproxy should be (KProxy k). But we still have to infer the kind of the occurrence of 'KP on the left. HEAD sees the kind of kproxy and infers that 'KP should have kind (KProxy k). My branch, on the other hand, doesn't have any reason to constrain the kind of 'KP, and so it gets (KProxy Any), which quickly causes trouble.
> 
> The fix is easy: add a kind signature.
> 
> I see two ways forward, corresponding to the choices for the kind of (~) above:
> 
> 1. Make (~) homogeneous and introduce a new constraint (~~) that is like (~) but heterogeneous. We resign ourselves to explaining the technical, subtle difference between (~) and (~~) into perpetuity.
> 
> 2. Make (~) heterogeneous. Some people will have to add kind annotations to their code to port from GHC 7.10 to GHC 8.0. But these kind annotations will be fully backward-compatible, and won't require CPP, or warnings, or any other bother. We may have to explain why kind inference around (~) is weaker than it was before.


More information about the ghc-devs mailing list