[Haskell-cafe] Type families versus functional dependencies question

Manuel M T Chakravarty chak at cse.unsw.edu.au
Mon Jul 7 02:21:16 EDT 2008


Alexey Rodriguez:
>
>
> On Fri, Jul 4, 2008 at 5:03 AM, Manuel M T Chakravarty <chak at cse.unsw.edu.au 
> > wrote:
> The problem is that blah's type is ambiguous, as f does only occur  
> as an argument to the type family.  If you'd define
>
>
>  class Blah f a where
>    blah :: a -> f -> T f f a
>
> (and change the rest of the program accordingly) then all will be  
> fine.  See this thread for a more in-depth discussion of the problem:
>
>  http://www.haskell.org/pipermail/haskell-cafe/2008-April/041385.html
>
> Yes, I was afraid that this was the case. However, the question  
> remains on whether my functional dependencies encoding is correct. A  
> correct encoding would help me understand this typing problem a bit  
> more. Especially, now that Claus showed that adding an equality  
> constraint makes this program work!

For this particular program, you could argue that the signature is not  
ambiguous as T is unary; hence, in (T f f a) only the (T f) is really  
a type family application and so the second occurrence of 'f' should  
make the signature unambiguous.  This is the reason why Claus'  
encoding works and why your FD translation works.  I will have a look  
at whether I can improve the implementation in GHC to be smarter about  
handling such higher kinded TFs.

Thanks for the example program!

Manuel



More information about the Haskell-Cafe mailing list