On Wednesday, January 12, 2005 12:00 PM you wrote: Ralf Hemmecke wrote: Well, I haven't checked whether it should really work, but shouldn't be:
Foo: with {
g: (n: PositiveInteger, k: PositiveInteger) ->
(P: PrimeFieldCategory, x: P)
} == add {
g(n: PositiveInteger, k: PositiveInteger ):
(P: PrimeFieldCategory, x:P) == {
(PrimeField(n), k::Integer::PrimeField(n)
}
}
be even better? Later William Sit wrote: In fact you just pointed a way to solve the problem! Notice that you are in effect constructing a domain! So first create this domain (call this anything else you like) fricas (1) -> )abbrev domain PPF PointedPrimeField --%PointedPrimeField PointedPrimeField(n:PositiveInteger):Cat==Dog where Cat == FiniteFieldCategory with foo:PositiveInteger->PrimeField(n) Dog == PrimeField(n) add foo(k)==k::Integer::PrimeField(n) fricas Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/3896265268149061013-25px.001.spad
using old system compiler.
PPF abbreviates domain PointedPrimeField
------------------------------------------------------------------------
initializing NRLIB PPF for PointedPrimeField
compiling into NRLIB PPF
compiling exported foo : PositiveInteger -> PrimeField n
Time: 0 SEC.After compiling, define in the interpreter fricas g(n, Type: Void
fricas g(7,
Type: PrimeField?(7)
and it works (in Axiom)! (Do not declare the types for g because n is not defined). Compiling g is still a problem in Axiom due to signature limitation. At least this way, inlining a complicated function is almost like a function call. The idea is: Since in creating domains (or any other types of constructors), we are in effect creating a function(the domain constructor PPF is a function of sorts, or functor) and the compiler can take dependent types in its signature,structurally: PPF(n:PositiveInteger)==PrimeField(n) with foo so it should be able to compile something like g by lifting it to the package level. So here is another way using package. spad )abbrev package FOO Foo Foo(n:PositiveInteger, spad Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/6339949729126981292-25px003.spad
using old system compiler.
FOO abbreviates package Foo
------------------------------------------------------------------------
initializing NRLIB FOO for Foo
compiling into NRLIB FOO
compiling exported point : () -> PrimeField n
Time: 0 SEC.After compiling, we can use: point()$Foo(n,k) in any computation in compiler code (and in interpreter). In the interpreter you can call this bar(n,k): fricas bar(n, Type: Void
fricas bar(7,
Type: PrimeField?(7)
Can someone give an example where the signature of bar: bar: (n: PositiveInteger, k: PositiveInteger) -> PrimeField(n) is actually needed? spad )abbrev package FOO2 Foo2 Foo2(n:PositiveInteger, spad Compiling FriCAS source code from file
/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/3511022708306225656-25px005.spad
using old system compiler.
FOO2 abbreviates package Foo2
------------------------------------------------------------------------
initializing NRLIB FOO2 for Foo2
compiling into NRLIB FOO2
compiling exported point : () -> PrimeField n
Time: 0 SEC.fricas point()$Foo2(13,
Type: PrimeField?(13)
|