Hello Waldek, the code below is a cut down version of what I would like to have. In fact, the code works if I replace the line
Y: (E: EuclideanDomain, A: QEtaAlgebra E) -> QEtaComputationCategory(E, A) by Y: QEtaComputationCategory(C, F) and use Y instead of Y(C, F) in the body of algebraBasis. However, I would like Y to be a functor, because, roughly speaking, there would be another parameter F2: QEtaAlgebra(C) and I would like to call a function from Y(C, F2). I've seen a similar construction in Aldor. https://github.com/pippijn/aldor/blob/master/aldor/lib/algebra/src/multpoly/multpolydom/sm_rmp.as#L28 ============================================================= RecursiveMultivariatePolynomial0(_ UP: (R: Join(ArithmeticType, ExpressionType), avar: Symbol == new() ) -> UnivariatePolynomialAlgebra(R), _ R :Ring, _ V : VariableType): RecursiveMultivariatePolynomialCategory0(R,V) with { univariate: % -> UP %; ++ `univariate(p)' returns `p' as a univariate polynomial ++ w.r.t. its main variable. This assumes that `p' ++ is not a constant. multivariate: (UP(%), V) -> %; ++ `multivariate(p,v)' returns `p' as a multivariate ++ polynomial whose main variable is `v'. An error ++ is raised if one coeffcient of `p' does not have ++ degree zero w.r.t. `v'. } == add { import from Boolean, R, V, Z, MI, NNI; RVU ==> Record(var:V,terms:U); U ==> UP(%); Rep == Union(base:R,poly:RVU); ...... } ============================================================= There, the R in the definition of the argument UP is local and not the same as the R: Ring (second argument of RecursiveMultivariatePolynomial0). When I compile the attached qq.spad, I get the following... ------------------------------------------------------------------------ initializing NRLIB QETAPKG1 for QEtaPackage1 compiling into NRLIB QETAPKG1 compiling exported algebraBasis : (F,List F) -> List F ****** comp fails at level 4 with expression: ****** error in function algebraBasis (SEQ (LET (|:| |y| (Y C F)) (|initialize| | << m >> |)) (|exit| 1 (|return| 1 (|basisElements| |y|)))) ****** level 4 ****** $x:= m $m:= (List A) $f:= ((((|y| #) (|m| # . #1=#) (|t| # #) (|m| . #1#) ...))) >> Apparent user error: Cannot coerce m of mode (List F) to mode (List A) Replacing A by F in the specification of Y, is not an option, since eventually, I like to call Y(C, F2) and it doesn't work anyway. It gives ------------------------------------------------------------------------ initializing NRLIB QETAPKG1 for QEtaPackage1 compiling into NRLIB QETAPKG1 compiling exported algebraBasis : List F -> List F Internal Error Error while instantiating type YCF Any idea how I can pass a functor in SPAD? 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 fricas-devel+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
)abbrev category QETAALG QEtaAlgebra QEtaAlgebra(C: CommutativeRing): Category == CoercibleTo OutputForm )abbrev category QETACAT QEtaComputationCategory QEtaComputationCategory(C: EuclideanDomain, F: QEtaAlgebra C): Category == with initialize: List F -> % basisElements: % -> List F )abbrev package QETAPKG1 QEtaPackage1 QEtaPackage1(C, F, Y): Exports == Implementation where C: EuclideanDomain F: QEtaAlgebra C Y: (E: EuclideanDomain, A: QEtaAlgebra E) -> QEtaComputationCategory(E, A) Exports ==> with algebraBasis: List F -> List F Implementation ==> add algebraBasis(m: List F): List F == y: Y(C, F) := initialize(m) return basisElements y