[Haskell] aosd 2007

2006-06-20 Thread Oege . de . Moor
   AOSD 2007: CALL FOR RESEARCH PAPERS
6th Conference on Aspect-Oriented Software Development
   http://www.aosd.net/2007/cfc/research.php
>> abstract submission by September 22, 2006 <<
--
The program committee especially welcomes 
submissions from researchers in functional programming 
on any topic relating to
aspect-oriented extensions of Haskell (or why you don't need them!)

___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] extensible records using associated types

2006-06-20 Thread Manuel M T Chakravarty
Barney Hilken:
> Similarly, it Lacks all the fields which r Lacks, except for N  
> itself. This is where we really need the ordering :<: to ensure that  
> m is not equal to N. There are two cases, m :<: N:
> 
>  >instance m :<: N, Lacks m r => Lacks m (N a r) where
>  >type Extend m b (N a r) = N a (Extend m b r)
>  >extend mm y (N x t) = N x (extend mm y t)   
> 
> and N :<: m:
> 
>  >instance N :<: m => Lacks m (N a r) where
>  >type Extend m b (N a r) = m b (N a r)
>  >extend mm y (N x t) = mm y (N x t)  

This is problematic as the instance heads are distinguished only by the
context; ie, both instances are for `Lacks m (N a r)'.  Haskell's
instance selection mechanism (with or without associated types) selects
instances purely by looking at the arguments of the class; hence, you
cannot use instance context as a kind of guard to guide instance
selection.

Manuel


___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] extensible records using associated types

2006-06-20 Thread Barney Hilken
The implementation of records using types data N a r = N a r might  
well be inefficient, and I don't know enough about the workings of  
the compiler to see whether it could be improved by unboxing and  
strictness. But the real point of my post was the classes Contains,  
Lacks and Disjoint which give you extensibility. To give another  
example, if Haskell had non-extensible records {N1 = x1, ..., Nn =  
xn} of type {N1 :: a1, ..., Nn :: an} we could use the same technique  
to make them extensible.


Assume we can represent the field names N somehow as values (N ::  
Constructor N). Then we can define instances of the form


instance Contains Nj {N1 :: a1, ..., Nj :: aj, ..., Nn :: an} where
type Project Nj {N1 :: a1, ..., Nj :: aj, ..., Nn :: an} = aj
		type Delete Nj {N1 :: a1, ..., Nj :: aj, ..., Nn :: an} = {N1 ::  
a1, ..., Nn :: an}

project Nj {N1 = x1, ..., Nj = xj, ..., Nn = xn} = xj
		delete Nj {N1 = x1, ..., Nj = xj, ..., Nn = xn} = {N1 = x1, ..., Nn  
= xn}


instance Lacks M {N1 :: a1, ..., Nn :: an} where
		type Extend M a {N1 :: a1, ..., Nn :: an} = {M :: a, N1 :: a1, ...,  
Nn :: an}
		type extend M x {N1 = x1, ..., Nn = xn} = {M = x, N1 = x1, ..., Nn  
= xn}


	instance Disjoint {N1 :: a1, ..., Nn :: an} {M1 :: b1, ..., Mm ::  
bm} where

type Union {N1 :: a1, ..., Nn :: an} {M1 :: b1, ..., Mm :: bm}
= {N1 :: a1, ..., Nn :: an, M1 :: b1, ..., Mm :: bm}
union {N1 = x1, ..., Nn = xn} {M1 = y1, ..., Mm = ym}
= {N1 = x1, ..., Nn = xn, M1 = y1, ..., Mm = ym}

Of course, there are a lot of these (exponential in the number of  
field names!) so you don't really want to generate them all. But  
exactly the same classes (modulo the definition of Constructor, which  
should be hidden anyway) give you extensibility, so any code you  
write will work with either implementation.


Barney.

___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell