[Haskell-cafe] Fundeps and overlapping instances

Gábor Lehel illissius at gmail.com
Tue Jun 5 14:25:08 CEST 2012

On Tue, Jun 5, 2012 at 4:18 AM, Etienne Laurin <etienne at atnnn.com> wrote:
> Thanks for the idea. Here it is.
> http://hackage.haskell.org/trac/ghc/wiki/TFvsFD
> I posted my comments on the matter along with many additional comments
> and examples that I found.


One part is confusing me.

In the section on "Partial application", you write:

> Type synonyms can manipulate constraint kinds but can not use them. The following code doesn't make sense.
> class (f :<$>: a) ~ b =>  FMap (f :: * -> * -> Constraint) a b
>  where type f :<$>: a
> instance FMap f (HJust a) b
>   where type f :<$>: (HJust a) = f a b => b

The class definition looks like it's meant to parallel the earlier FDs
version of FMap by using the "standard encoding" of FDs with TFs, but
the instance declaration doesn't. Is it meant to be demonstrating
something else?

The encoded version would be:

instance (f a b) => FMap f (HJust a) (HJust b)
  where type f :<$>: (HJust a) = HJust b

and I think this actually demonstrates a *different* limitation, namely that

> The RHS of an associated type declaration mentions type variable `b'
>   All such variables must be bound on the LHS

which means that the standard encoding doesn't work for this case.

More information about the Haskell-Cafe mailing list