[Haskell-cafe] [ghc-proposals/cafe] Partially applied type families

Richard Eisenberg rae at cs.brynmawr.edu
Tue May 30 19:50:13 UTC 2017


> On May 24, 2017, at 3:57 AM, Alejandro Serrano Mena <trupill at gmail.com> wrote:
> 
> I would like to advise against this idea of apartness guards. I've tried myself some years ago, and I remember them being quite complicated to describe. The main problem is that apartness may end up introducing some sort of backtracking in the type checking process -- something completely undesirable. Furthermore, they make the work of the overlapping checks much harder.

Do you recall an example of where things went wrong? It seems to me that GHC does this today. If I have

> instance C (Maybe a) where ...
> instance {-# OVERLAPPING #-} C (Maybe Int) where ...

then GHC won't choose the first instance unless it knows that `a` is apart from Int. Indeed, it is possible to write a program that is accepted with only the first instance in scope but is rejected when the second one is, too. Under instance guards, this could be written

> instance C (Maybe a) | a /~ Int where ...
> instance C (Maybe Int) where ...

and then both instances stand alone and make sense independent of one another.

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170530/895a268d/attachment.html>


More information about the Haskell-Cafe mailing list