On 09/26/2017 01:53 PM, oldk1331 wrote:
>> I would rather add a function retractable?: % -> Boolean that does 
>> exactly such a check and transform the specification into:
> 
> Errr... Wouldn't that be something like retractIfCan : % -> Maybe R
> 
> Which is a total function.

Of course you can go via Maybe(R), but then I'd have to check afterwards
whether the result is in R. This is why I want retractable? in advance.
Remember, the problem with memory allocation was the issue with which
this whole discussion started. retractable? returns a boolean and that
is not much memory usage.

> Which means Maybe is more fundamental than RetractableTo.

Of course, you can see it that way, but FriCAS has no Monads.

> Which means Maybe should not export 'retract', because Maybe/unwrap
> is more fundamental than RetractableTo/retract/retractIfCan.

I don't understand. We need a function Maybe(R) -> R, no? Whether it's
called unwrap or retract is not yet the point.
I'd call Maybe fundamental for FriCAS if one could chain (possibly
failing) computations, i.e., forget about error checking at all.
But that would require an appropriate concept of Monad for FriCAS. I
don't see how this would work in FriCAS.

>> I'd be actually happier if -> only denotes total functions
> 
> If that's what you want, you should not try to restrict the input, 
> instead return Maybe as output.

Because it is not the same. If I want an element of % as return type and
not Maybe(%), then why should I introduce Maybe(%)?
Would you want /: (%,%) -> Maybe(%), because division by 0 causes trouble?

> But for fundamental Maybe domain itself, well, something has to be
> non total.

Yes, that's clear. I only thought, that retractable?(%) would be a nice
notation to show in source code what the specification (from my last
mail) says.

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