[Haskell-beginners] From Functional Dependencies to Type Families

Stephen Tetley stephen.tetley at gmail.com
Thu Dec 3 04:38:48 EST 2009

Hi Adolfo

This is quite a tricky one and I haven't got a proper answer
(hopefully someone will come along with one soon). But I've
an initial observation:

Longhand (i.e. without the type class - but relying on previously
defined instances) the type family version of buildlist on functions

buildList_fun l x = \y -> build' (x:l) y

Asking for the type at the GHCi prompt gives:

  :: (BuildList r) => [Build r] -> Build r -> Build r -> r

Whereas for the fun dep version

build_fun l x y = build' (x:l) y

The type is:

build_fun :: (BuildList a r) => [a] -> a -> a -> r

Crucially the last part of the type is r.

Why you can't type your TF version seems to be because the answer type
of the continuation is fixed to a not r.
(the fun dep version is also a multi parameter class so you are
allowed a different answer type).

[I'm calling out to the gallery for help at this point!].

Best wishes


More information about the Beginners mailing list