On Sat, Mar 03, 2012 at 09:48:36PM +0100, Ralf Hemmecke wrote:
> Hi Sergei,
>
> On 03/03/2012 10:32 AM, Serge D. Mechveliani wrote:
>> And I am going to build constructions like this:
>>
>>      constr :=  UPConstr(x, FrCons("Int" :: Symbol))
>>
>> And to analyse it like this
>>
>>    f(constr) ==
>>           constr case of Fr =>
>>                              constr' := frConstrArg constr
>>                              process the argument construction  constr'
>>           constr case of UP' =>
>>               x       := upConstrVar  constr
>>               cConstr := upConstrCoef constr
>>               process x and the coefficient domain construction  cConstr
>>
>> This approach looks rather complex, and even requires to introduce a
>> category.
>> I thought of SExpression. But, for example,
>>                            convert[UP', x, coefConstr'] :: SExpressin
>>
>> requires of  UP', x, constr'  to be of the same type. Right?
>> One neds to union the  constructor tags,  parameters (like x),
>> and domain constructions  into a certain type  U,  and to program
>> processing the data in  List U  ...
>
> Can you be a bit more precise? All I see is some code that looks like  
> Haskell and would certainly not be the way it would be programmed in  
> SPAD. It would be helpful, if you state, what you actually want to  
> achieve. From what I've read in your mail, all I can say is that you  
> want something like Any, but not encoding every type. In other words, I  
> think that you want tagged unions, but I'm not quite sure.
>
> However, if you want something like Any or tagged union, then it looks  
> like you basically want to throw away the type information. I'm sure  
> there is some better way to achieve your goal in SPAD, but what is your  
> goal?
>

The question can be reformulated:  what Spad has for the  tagged union?.

The initial goal is explained in the first my letter on this subject.
I repeat:
to define a type  DomConstr  
for an explicit   symbolic representation of a domain construction 
-- for a domain built by any correct composition of
         INT, Fraction, UP, POLY, ResidueRingOfEuclideanRing.

(let it be this small set, so far) 
-- each of these constructors has its individual tuple of argument types.

It must be so that a Spad program
could process   constr : DomConstr  as a first-class data, in particular,
to extract each part of   constr : DomConstr.
For example, if   constr : DomConstr  represents the domain 
                                                 UP(x, Fraction INT),
then, it is possible to extract from it the  
 tag "UP",  variable x,  (construction of Fraction INT) : DomConstr,
 tag "Fraction",  (construction of INT) : DomConstr.

I do not think that this needs `Any'.
In Haskell, it is done by a tagged union.
In Spad, I do not find tagged union.
(1) I tried to define domains and type union, as in my first letter.
(2) I thought of SExpression.
(3) In my second letter I applied Records.
Records do work for this goal, but they do not so precisely fit this goal.
For example, is it possible to define  DomConstr  as a  
                                       tagged union of several records?

Thanks,

------
Sergei
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to