I wish to thank all of you for your comments. In fact, the solutions you proposed mostly coincided with mine (including the one using type families) but, in my opinion, they are more cumbersome than the prefixed names solution.
Going back to my example: f x = open $ open x where: data Foo = { open :: Bar } data Bar = { open :: String } there are basically two possibilities to assign types to the "open" functions, either the first is "open :: Foo -> Bar" and the second is "open :: Bar -> String" or the converse. It's clear that the type checker might explore these two possibilities until one of them typechecks. Hence, the possible outcomes of this search would be: 1 - No possible assignment works so the typechecking phase fail. 2 - One possibility matches, then it's undertaken. 3 - Two or more possibilities match so an ambiguity is found which can be solved only by the programmer specifying the type of the open function explicitly, which is just like using the prefix based solution. Would you trust a type checker behaving like this? My answer is no, as the type checker would be making assumptions about my intentions when I wrote the expression "open $ open x". I would rather prefer the compiler to signal this as an error, forcing me to be more explicit about my real intentions that I could actually find to be wrong (i.e. a bug would be accepted silently). Concerning TDNR, I read about it just a while ago but, as far as I can remember, it's just a syntactic dissertation on the subject while the type checking matter is not touched. Thank you again. C. On Wed, Jan 13, 2010 at 8:28 PM, Evan Laforge <qdun...@gmail.com> wrote: >> Now, in Haskell we have type inference, which is "The Good Thing" as >> it allows to "validate" your program at compile time. Hence, the idea >> coming up to my mind is that type inference actually forbids a >> type-directed resolution of names as in C++ or Java. >> >> Is this correct? > > There is a proposed extension which is not implemented but was > discussed on the list a while back, maybe you'd find this interesting: > > http://hackage.haskell.org/trac/haskell-prime/wiki/TypeDirectedNameResolution > > Search back in the archives for TDNR and you should turn up some threads. Cristiano _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe