On 23 October 2016 at 08:20, oldk1331 <[email protected]> wrote:
>> Could you provide an example implementation of map for Functor(E) in
>> AbelianMonoidRing?
>>
>> Given that over AbelianMonoidRing there are functions like
>>
>>   f(a:R):(% -> %) == (x:%):% +-> a * x
>>
>>  I do not see how this is possible. Perhaps I am missing something.
>
> Again, what's important to implement "map" is signature, this will be
> more clear in Monad.
>
> So for AbelianMonoidRing(R,E) we implement Functor(E):
> map : (E->E, %)->%
> map(f, x) ==
>   zero? x =>0
>   monomial(leadingCoefficient x, f degree x)+map(f, reductum x)
>
> Your example function f has signature of '%->%', not 'E->E'.
>

Thank you for your patience and explanation. I now have a better
understanding.  I still think however that no significant
documentation is lost by removing the definition of map and the ++
comments from AbelianMonoidRing. In its place we now have information
about 'Functor(R)' and possibly also 'Functor(E)'. I think this is an
overall gain.  I would like to encourage Waldek to adopt your original
suggestion.

---

>> Could you give some examples of the disadvantages of such automatic
>> currying?
>
> Automatic currying is not that useful, especially in Spad:
> Say we have f:(A,B)->C and f:(A,B,C)->D, then f(a:A) will be a nightmare
> for both human and compiler.
>

This is of course a completely different subject but I do not see any
nightmare in

  f(a)@(B->C)

versus

  f(a)@((B,C)->C)

But I do see how it could considerably complicate automatic function
selection as implemented in the interpreter.

> Automatic currying will only curry its first argument, often we need to
> curry other arguments, then what to do?  Use 'flip'?
> For f:(A,B)->C and a:A,b:B compare
> x+->f(a,x)  vs.  f(a)
> x+->f(x,b)  vs.  (flip(f))(b)
>
> Manually currying (aka. write single argument anonymous function) is useful,
> automatic currying, not so much.
>

I agree that the anonymous function notation is clearer in most cases
but it seems a pity to have to introduce a dummy variable. SPAD in
FriCAS (and perhaps still in BOOT?) used to support a briefer notation
like

 f(a,#1)
 f(#1,b)
 f(#1,#2,c)

 etc.

but I think this was removed a few years ago.

Bill.

-- 
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