On 03/01/2017 11:37 AM, oldk1331 wrote: >> Let me explain with the simpler division. More correct would be >> something like >> >> /: (Integer, NonZeroInteger) -> Fraction(Integer)
> The problem with this approach is that NonZeroInteger doesn't have > the nice features Integer has: NonZeroInteger is not AbelianGroup, so > you don't have "add" in it. And why does that matter. Do you need addition to do division? NonZeroInteger does not necessarily need to export all functionality of Integer (and as you say, it cannot). The / function should require what it needs and only that, not more. Maybe to give the whole thing mathematical sense, one would have to state all the axioms that connect / with *. > There are much fewer functions in NonZeroInteger with signature > %->%, which means NonZeroInteger doesn't "propagate" well. So you > still have to add checks somewhere and signal errors, or propagate > the error through Maybe. No, the only function that might have a check is coerce: Integer -> NonZeroInteger But even there (just like what I said in the beginning) you only need a check if it is not specified that this coerce only works for non-zero input. OK, I agree, to be consistent... when I want to move to total functions, I should have a check for 0 in this coercion function. So my idea just says that as long as you can do computations that don't leave NonZeroInteger, there is no need to do the check again when you pass such an element to /, because by the type it is ensured that the element is nonzero. 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.
