BTW, the type Any is like an "infinite" Union unfortunately it does
not export 'case'.  So for the application that you illustrate perhaps
it would be better to be more explicit and write an actual Union. E.g.

-----------------------------------------
ANY1          ==> AnyFunctions1
AnyLex        ==> Union(Integer,String,Float)
SetAnyLexList ==>
             Record( val : AnyLex, remList : List String)

)abbrev package FOO Foo
Foo() : with    p : List String -> SetAnyLexList  ==
 add
   p(lexs : List String) : SetAnyLexList ==
                              [1::Integer, rest lexs]
-----------------------------------------


(2) -> x:=p["a"]

   (2)  [val= 1,remList= []]
         Type: Record(val: Union(Integer,String,Float),remList: List(String))
(3) -> x.val case Integer

   (3)  true
                                                                Type: Boolean
(4) ->




On Tue, Feb 14, 2012 at 9:19 AM, Bill Page <[email protected]> wrote:
> Record does not need SetCategory.  Could you give specific reference from 
> docs?
>
> FriCAS has very poor support for List  and Record that contain types
> as values. (This is better suppored in OpenAxiom so there is hope that
> it can also be in FriCAS.)
>
> You could try eliminating the 'dom' component of the Record.  The Any
> type already includes it anyway. Perhaps there is also a conflict of
> function names versus tags.
>
> -----------------------------------------
> ANY1          ==> AnyFunctions1
> SetAnyLexList ==>
>             Record( val : Any, remList : List String)
>
> )abbrev package FOO Foo
> Foo() : with    p : List String -> SetAnyLexList  ==
>  add
>   p(lexs : List String) : SetAnyLexList ==
>                              [coerce(1) $ANY1(Integer), rest lexs]
> -----------------------------------------
>
>
> (2) -> x:=p["a"]
>
>   (2)  [val= 1,remList= []]
>                                 Type: Record(val: Any,remList: List(String))
> (3) -> x.val
>
>   (3)  1
>                                                                Type: Integer
> (4) -> dom(x.val)
>
>   (4)  (Integer)
>                                                            Type: SExpression
> (5) ->
>
>
> On Tue, Feb 14, 2012 at 2:54 AM, Serge D. Mechveliani <[email protected]> 
> wrote:
>>
>> In  docs  it is written that  Product  and  Record  need  SetCategory  for
>> each component. And I thought that  Any  has not  SetCategory,  I thought
>> that Any is more generic than Set.
>> But now, I try in the interpreter:
>>
>>    -> has(Any, SetCategory)
>>       true                    : Boolean
>>
>> Really, is  Any  of SetCategory ?
>> Now, assuming "yes", I try the code (which is close to what I need):
>>
>> -----------------------------------------
>> ANY1          ==> AnyFunctions1
>> SetAnyLexList ==>
>>              Record(dom : SetCategory, val : Any, remList : List String)
>>
>> )abbrev package FOO Foo
>> Foo() : with    p : List String -> SetAnyLexList  ==
>>  add
>>    p(lexs : List String) : SetAnyLexList ==
>>                               [Integer, coerce(1) $ANY1(Integer), rest lexs]
>> -----------------------------------------
>>
>> Is this all right?
>> After compilation, I run it under the interpeter:
>>
>> --------------------------------------------------------------
>>  ...
>>  |$ConstructorCache|
>> 0 errors, 4 warnings
>> ------------------------------------------------------
>>   Foo is already explicitly exposed in frame initial
>>   Foo will be automatically loaded when needed from
>>      /home/mechvel/ghc/axiomInterface/fromA-aim/FOO.NRLIB/FOO
>>
>> (5) -> p ["a"]
>>
>>   >> System error:
>> FUNCALL: ((|latex| ((|String|) $)) T (ELT $ 8)) is not a function name;
>> try using a symbol instead
>> -------------------------------------------------
>>
>> If I change `SetCategory' to `Type', then the compiler again compiles this.
>> But  has(Type, SetCategory) = false.
>> So, should not it report an error?
>>
>> Then, in the interpreter, it shows in the result  NIL  intstead of  Integer
>> in the first component of the record.
>> I suspect that the reasons for all this are similar to ones explained in the
>> last response of Waldek to by question of "subtle f signature"
>> [ 1) a certain bug,  2) the specifics of the Interpeter mode,  ... ].
>>
>> I hope that the whole my parsing program will still work with
>> Record(dom: SetCategory, ...),  because the function of this kind is used
>> by Spad functions.
>> But  1) it needs trying,
>>     2) anyway it will be nice to see the explanation for this above code
>>        with Record.
>>
>> 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.
>>

-- 
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