Bill Page <[email protected]> writes:

| Sorry. This is not an attempt to solve any specific problem. 

Ah!  Maybe I should refrain from trying to answer questions then :-/

| The goals
| were specified earlier in this thread. See also message in related
| thread LazyList by Martin Baker.
| 
| On Wed, Nov 9, 2011 at 3:08 PM, Gabriel Dos Reis wrote:
| > Bill Page <[email protected]> writes:
| >
| > | 2) If yes, is it useful? How to use it?
| >
| > I do not know how useful it is until you've shown concrete examples
| > (Spad) illustrating why you wrote it in the first place and what it is
| > useful for.
| 
| An example usage was already given earlier in this same thread which
| you omitted when you quoted.

then, do not hesitate to present it again.  There are too many things
going on and I am trying to focus on one problem at a time, otherwise it
is total chaos.  It is highly nontrivial to triage between what is valid
assumption, what is invalid, what is just bug, and what is plain
misunderstanding. 

| >  IMList(): Monad(Integer,List) == add
| >    unit ( x:Integer ): List Integer == list x
| >    mult ( x: List List Integer ): List Integer = concat x
| 
| Note especially the 2nd argument to Monad.

In OpenAxiom, the second argument does not match the expected type.

| >
| > | 3) Why doesn't this compile?  (Discussion of function versus functor.)
| >
| > It compiles in OpenAxiom.  I do not see a fundamental reason why it
| > should not compile in other AXIOM flavours.
| >
| 
| I presume you mean:
| 
|   Monad(A: SetCategory, M: SetCategory -> SetCategory): Category == with
|     unit: A -> M A
|     mult: M M A -> M A
| 
| Yes that does compile. 

Great!

| Is M compiled as a function or as a functor? 

In OpenAxiom, it is elabporated as a parameter with function type --
which is also what I read from your code.  Also, remember that a
category definition is barely type checked.  You can smuggle in there
just about anything and we have seen that in the past.

| If function what does M A mean in the signatures for unit and mult ?

In OpenAxiom, M A is an expression designating a domain that satisfies
SetCategory.  Did you have a different expectaion?

| The code that does not compile is when we try to use it.

In OpenAxiom, the category definition is just fine.  It is just a
category definition; there is no high hope there.
However, the instantiation with arguments Integer and List is not type
correct, because the functor List  does not have the type expected by Monad.

| See above or
| 
| 
http://axiom-wiki.newsynthesis.org/SandBoxMonads#[email protected]
| 
| > | 4) Is there another way to write it that does compile and that would
| > | be a useful way to represent a monad-like construction in Axiom?
| >
| > It compiles; I have no idea how you wanted to use it, so I cannot tell
| > you whether it is useful.
| >
| > | 5) What would have to change (if anything) in Axiom to allow it or
| > | something similar to compile?
| >
| > At the moment, the definition you gave (when properly written in Spad
| > syntax) compiles.  That alone does not say much to me, because I do not
| > know exactly how you are using it.  So far it is just a category!
| >
| 
| Is it really a category?

Yes, it is.  Is there any indication that it should not?

| Can you show example code that uses it successfully?

No, I did not conceive of it in the first place!  I honestly to not have
an idea of what problem you are trying to solve.

While looking at this, I realize there is a bug in the OpenAxiom
compiler where a conversion of constructor to a general function type is
not compiled correctly.  Fixed.  See example here:

http://svn.open-axiom.org/viewvc/open-axiom/1.4.x/src/testsuite/compiler/ctor-mapping.spad?revision=2459&view=markup

The handling in the interpreter is a completely different story.

| > | 6) Should we be able to pass functors as arguments, store them in
| > | variables, etc. the way we do with functions (and as implied in the
| > | original Axiom literature)?
| >
| > Which functors do you want to pass?  Example of code.
| >
| 
| I am sorry you missed the example I gave earlier in this thread.

Thanks.

| > | 7) What type (if any) should be associated with a functor?
| >
| > Every functor in AXIOM has a type.  You get it by executing
| >
| >   )boot getConstructorSignature ctor
| >
| > where <ctor> is the name of the constructor you want, e.g. 'List,
| > 'Integer, etc.
| 
| In FriCAS I get with Complex for example:
| 
| )boot getConstructorSignature 'Complex
| 
| (|getConstructorSignature| '|Complex|)
| Value = ((|Join| (|ComplexCategory| |#1|)
|           (CATEGORY |package|
|            (IF (|has| |#1| (|OpenMath|))
|                (ATTRIBUTE (|OpenMath|))
|                |noBranch|)))
|          (|CommutativeRing|))
| 
| --
| 
| How would I write that type in an argument list in SPAD? 

That expression is not closed -- it mentions the free variable #1.
Assuming it is in scope, it is just

    ComplexCategory #1 with
       if #1 has OpenMath then OpenMath
       CommutativeRing

| Really this issue is: Can I pass a functor as a parameter?

Yes.

| If so, how can I write  it's type?

In Spad (library), in a way that respect type expectations.  
See the example in the OpenAxiom repo above.

-- Gaby

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
open-axiom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/open-axiom-devel

Reply via email to