> 
> >> BTW: Why can I not use this for List PI?
> >>
> >>    >> Apparent user error:
> >>    Cannot coerce lc 
> >>       of mode (List (PositiveInteger)) 
> >>       to mode (List (Integer))
> >>
> >> The other way round would make sense for me.
> >> But PI is a subset (and subtype) of INT ...
> >> What am I missing again? These errors are not
> >> so apparent for me ;-)
> 
> Why do you say, you cannot?
> 
> L==>List PI
> cumSum(l: L): L == (empty? l => []; s:PI:=first l;[(s:=s+i) for i in l])
> 
> But otherwise the question you were posing is not about this code but
> rather more general.
> 
> If there is a function coerce: A -> B, by what rule would there be a
> function
> 
>     coerce: Foo(A) -> Foo(B)
> 
> ? In our case Foo would be List, but if the compiler special lifting
> feature built in for List, then why not for MyList (which would be my
> implementation of List, but not using List at all)?
> 
> Do you see what the problem in general is? As long as there is no code
> in the definition of Foo that exports and implements such a coerce,
> there is no way, for the compiler to give you that (except someone
> builds it into the compiler).

Actually, there is general definition which is built into
interpreter.  Namely, if there is 'map' from 'Foo(A)' to 'Foo(B)'
and 'coerce' from 'A' to 'B', then interpreter can synthetise
coercion from 'Foo(A)' to 'Foo(B)', see Weber article.

I am not sure why interpreter is not doing this in the case above,
maybe too much guessing (due to 0) even for interpreter.  And
as you wrote Spad compiler is not doing such things.

-- 
                              Waldek Hebisch
[email protected] 

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to