[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell-cafe
Subject:    Re: [Haskell-cafe] Top Level etc.
From:       Benjamin Franksen <benjamin.franksen () bessy ! de>
Date:       2005-01-19 20:22:45
Message-ID: 200501192122.45891.benjamin.franksen () bessy ! de
[Download RAW message or body]

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic