On 7/24/26 15:46, Waldek Hebisch wrote:
>> Oh, I am fine with two domains. Whether with parameter or one domain
>> inherits from the other or both from a common category (with default domain)
>> or a common domain is to be discussed. Important is that
>>
>> setFormats! in FormattedOutput should work.
>>
>>
https://fricas.github.io/api/FormattedOutput.html
>>
>> Currently, I am somewhat against a parametrized domain, so that it would be
>> easier to convert a string just a domain name without parameter) into a
>> formatting type. (Note at some time in the future we might want to deals
>> with the Format... domains in the same way as with ")set output algebra
>> on/off".
>
> We can define "shortcut" domains like this:
>
> Format1D == Format1DInternal(true)
Yes, OK, if that makes sense.
Nevertheless, I still think that telling Format1D to generate things
differently, is not the right way. Format1D works on OutputForm. It is
just "formatting" what OutputForm says.
AFAIU, the machinery that translates a constructor structure into
OutputForm, i.e.
constructor_to_OutputForm(con) == constructor_to_form(con, 'out_form)
should, for example take care of producing an appropriate OutputForm
that is then formatted nicely by Format1D. In other words,
((CliffordAlgebra(1,Fraction(Polynomial(Integer)),matrix
[[-1]]))::OutputForm) pretend SEX
should not give this
(CliffordAlgebra 1 (Fraction (Polynomial Integer)) (MATRIX () (ROW - 1)))
but rather this
(CliffordAlgebra 1 (Fraction (Polynomial Integer)) (BRACKET (AGGLST
(BRACKET (AGGLST - 1)))))
Then Format1D will generate
CliffordAlgebra(1,Fraction(Polynomial(Integer)),[[-1]])
Do you think that changing the generation of the OutputForm for a
constructor is the way to go? I think so.
Otherwise create a domain, Format1D, that generates for
matrix([[a,b],[c,d]]) always just "[[a,b],[c,d]]" (not only in type
arguments) and another one, Format1DInput, that generates
"matrix([[a,b],[c,d]])".
>> In fact, sometimes I wished that in a session I could enter some command
>> that appreviates a complicated type like
>> Fraction(UnivariatePolynomial('x,Integer)) to RF(Integer,'x) or even RFZx
>> and the type printing mechanism should apply my abbreviation wishes.
> That would need pattern matching on parts of type. Case above looks
> easy to match. Main trouble is with matching hairy values (as some
> users have noticed pattern matching for expressions has its quirks).
Well, pattern matching on constructurs with domain arguments would
already make me partially happy. And if for some non-domain parameters
pattern matching does not work, then it is just not improving the
current situation. In total, anything that allows to finetune the
prining of types as a user I would count as progress.
In my work I came across types that were quite longish with repeated
subdomains. To really check the argument structure then is quite
cumbersome and
> )boot $abbreviateTypes := true
does not really help there.
> We could extend this machinery, as long as we deal with "pure" types
> it is not hard because we essentially deal with a tree. Values
> are more problematic as they can be anything.
I don't know what exactly you propose. What is in my opinion important
is that a user can influence how a type is printed, i.e. the constructor
tree structure should be documented and public and
constructor_to_OutputForm should live in a SPAD package with options for
a user to modify the transformation at runtime.
In the end it is tree rewriting. Maybe RuleSet can help there. (Sorry, I
am just dreaming a bit.)
Ralf