[Haskell-cafe] Simple type-class experiment turns out not so simple...

wren ng thornton wren at freegeek.org
Tue Jan 10 18:26:03 CET 2012


On 1/9/12 7:54 AM, Luminous Fennell wrote:
> On Mon, Jan 09 2012 at 10:37 +0100, Steve Horne wrote:
>> On 08/01/2012 21:13, Brandon Allbery wrote:
>>>
>>> (Also, de facto I think it's already more or less been decided in
>>> favor of type families, just because functional dependencies are (a)
>>> a bit alien [being a glob of Prolog-style logic language imported
>>> into the middle of System Fc] and (b) [as I understand it] difficult
>>> to verify that the code in the compiler is handling all the
>>> potential corner cases right [mainly because of (a)].
>
>> Isn't Haskell doing some prolog-ish things anyway?
>
>> I thought the compiler must be doing unification to resolve type
>> inference within expressions.
>
> Even quite basic type reconstruction (e.g. for ML) needs unification, see e.g. Pierce
> TaPL chapter 22. The algorithm is rather easy to understand and implement.

Though it can be somewhat involved to optimize, since the naive 
implementation is really quite inefficient. If you don't want to worry 
about the details, there's always:

     http://hackage.haskell.org/package/unification-fd

-- 
Live well,
~wren



More information about the Haskell-Cafe mailing list