[Haskell] A puzzle and an annoying feature

Daan Leijen daan at cs.uu.nl
Thu Nov 25 09:50:05 EST 2004


Keean Schupke wrote:
> No, closed classes are different, here we are talking about lazy overlap 
> resolution, so
> if at _call_ time only one instance fits we choose it. Closing a class 
> is different.

A "closed class" directive however is an explicit specification that
makes the intention of the designer explicit in the program. Since
it would solve the puzzle in a rather elegant and explicit way, I
thought that it was interesting to mention.

All the best,
  -- Daan.

> 
>    Keean.
> 
> Daan Leijen wrote:
> 
>> Lennart Augustsson wrote:
>>
>>> [snip]
>>> So in what sense is this really ambiguous?
>>>
>>> I think it would be quite reasonable to allow the Puzzle module
>>> to compile, resolving `a' to be Bool.  I.e., if there is only one
>>> instance that can satisfy a constraint and there is no possibility
>>> of adding instances outside the compiled module, I think resolving the
>>> overloading makes sense.
>>
>>
>>
>> You may be interested in a recent paper by Bastiaan Heeren and Juriaan
>> Hage [1] about type class directives. The "closed" directive in that 
>> paper is more or less implied by your example. Here is a quote from 
>> the paper:
>>
>> "The main advantage of a closed type class is that we know the fixed 
>> set of instances. Using this knowledge, we can influence the type 
>> inference process. As discussed in the introduction to Section 2, we 
>> can reject definitions early on (in case the set of instances for a 
>> certain type class is empty) or improve a type variable to a certain 
>> type (in case the set of instances is a singleton)."
>>
>> All the best,
>>  -- Daan Leijen.
>>
>> [1] http://www.cs.uu.nl/~bastiaan/papers.html#typeclassdirectives
>>     (to appear in PADL 2005)      
>>
>>>
>>>     -- Lennart
>>> _______________________________________________
>>> Haskell mailing list
>>> Haskell at haskell.org
>>> http://www.haskell.org/mailman/listinfo/haskell
>>>
>>>
>>>
>>
>>
>> _______________________________________________
>> Haskell mailing list
>> Haskell at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell
> 
> 
> 
> _______________________________________________
> Haskell mailing list
> Haskell at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
> 
> 
> 




More information about the Haskell mailing list