Oh... I first thought that I do something wrong, but that looks more
like a bug.

I now extend FreeModuleCategory by

        if S has with (coerce: S -> Vector NonNegativeInteger) then
          totalDegree(p: %): NonNegativeInteger ==
             V ==> Vector NonNegativeInteger
             zero? p => 0
             "max"/[reduce("+", s::V, 0) for s in support p]

However, the correct way should be

   if S has with (coerce: % -> Vector NonNegativeInteger) then

There is a % instead of S right after "coerce".
Am I wrong?

The version with the S compiles find, but I wonder whether it really
does what I intend.

The version with the % gives the error below. I wonder where the
compiler gets the "A" from, because in the code of FreeModuleCategory
there is no A.

augmenting S: (SIGNATURE S coerce ((Vector (NonNegativeInteger)) A))
   compiling exported totalDegree : A -> NonNegativeInteger
   processing macro definition V ==> Vector NonNegativeInteger
****** comp fails at level 7 with expression: ******
error in function totalDegree

(SEQ (MDEF (V) (NIL) (NIL) (|Vector| (|NonNegativeInteger|)))
     (LET (|:| #1=#:G2594 (|Boolean|))
       (|zero?| |p|))
     (|exit| 1
      (IF #1#
          0
          (REDUCE |max| 0
                  (COLLECT (IN |s| (|support| |p|))
                           (|reduce| "+" (|::| |s| V) 0))))))
****** level 7  ******
$x:= (:: s (Vector (NonNegativeInteger)))
$m:= $EmptyMode
$f:=
((((|s| # #) (|last| #) (|rest| #) (|first| #) ...)))

   >> Apparent user error:
   Cannot coerce s
      of mode S
      to mode (Vector (NonNegativeInteger))


The code at
https://github.com/hemmecke/fricas/commit/7c46b41b82daccc0f9365d44f73186de8c759e98
seems to work.

That code keeps working if I replace the S by % in the category part.

        if S has (with coerce: % -> Vector NonNegativeInteger) then
             totalDegree: % -> NonNegativeInteger

Ralf

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to