[Haskell-cafe] Top Level etc.

Benjamin Franksen benjamin.franksen at bessy.de
Wed Jan 19 15:22:45 EST 2005


On Wednesday 19 January 2005 14:31, Keean Schupke wrote:
> I may have got this wrong, but I think you can do named instances
> without any extensions,
> by using datatypes and fundeps:
>
> data Instance0
> data Instance1
>
> instance0 :: Instance0
> instance0 = undefined
>
> instance1 :: Instance1
> instance1 = undefined
>
> class Named a b | a -> b
>     test :: a -> b -> b
> instance Named Instance0 Int
>     test _ a = a + a
> instance Named Instance1 Float
>     test _ a = a * a
>
>
> test instance0 1
> test instance1 1.5

Sure you can. However, the extension presented in the paper goes way beyond 
this (while still being conservative). For instance, named instances can be 
defined for standard Haskell98 classes, they don't need special class 
definitions as in your example. For a given class, standard unnamed instances 
may be used together with additional named instances. Another benefit of the 
proposal is that it slves a number of problems regarding multi-parameter 
classes quite elegantly.

But the reason why I mentioned the paper was that it offers a lot of insight 
into exactly what Ashley Yakeley was thinking about. Citing again:
> I have been musing on the connection between data-types, modules, 
> classes, and implicit parameters, and wondering if there might be some  
> grand scheme to tie it all together.

Neither I nor the authors claim that their proposal is the ultimate "grand 
scheme", yet. Still I think there are very interesting ideas in there that 
should be considered for experimental implementation or further research.

Ben


More information about the Haskell-Cafe mailing list