Closed Type Families: separate instance groups?

AntC anthony_clayden at
Thu Jun 4 00:53:41 UTC 2015

> Richard Eisenberg <eir <at>> writes:
> You can always define a helper closed type family
> and have an open type family instance just call a closed type family. 

Thank you Richard, you mean like:

    type family OpenF a


    type instance OpenF (Foo b c) = FFoo (Foo b c)
    type family FFoo a where
      FFoo (Foo Int c) = ...

OK. (Seems rather verbose.)

> Having closed type families, as opposed to branched instances,
> just seemed like a cleaner way to package the new functionality.
> There really wasn't much to it other than aesthetics,
> if I recall the conversations correctly.

I recall the conversation quite well.
(In fact I think it was me who suggested type family ... where ... )
I think it was less to do with aesthetics,
and more to do with reducing verbosity in a common use case.

It somehow doesn't seem as clean as old-fashioned overlapping instances.
(I agree it does seem cleaner than overlaps with FunDeps.)

It also BTW cuts us off from using Closed Families as Associated types
separated into their Class instances.
I think there's two use cases going on:
- one where we want to see all the instances together
   that fits well to type family ... where ...
- t'other where we want everything to do with a type constructor together
   that fits better with the separate instances


More information about the Glasgow-haskell-users mailing list