> 
> On 5 Oct 2009, at 21:06, Lennart Augustsson wrote:
> > OK, "just pairs" have no arithmetic, but one way of defining
> > arithmetic is to treat the pairs as complex numbers.  Or as mantissa
> > and exponent.  Or as something else.  So there's nothing wrong, IMO,
> > to make pairs an instance of Num if you so desire.  (Though I'd
> > probably introduce a new type.)

I was looking for one intuitive way of instantiating pairs of numbers as Num. 
One where i wouldn't have to look in the documentation to remember what (+) 
does. So considering all these examples of what pairs of numbers could be, i 
agree with Miguel Mitrofanov: "It's something that should not be done."

Two questions remain, i think:

1. How can i have some notion of addition and subtraction for something that i 
don't want to put in the Num class?

That's easy: I could just write a class that defines binary operators (like 
(+~) and (-~), for example). I don't get  the fanciness of (+), but that's 
okay.

2. How can i use numeric literals to construct values, whose types are not in 
the Num class?

Haskell could provide a class IsNumber (like IsString for string literals). Is 
that something we would want?

BTW, interesting discussion, thanks!

Sönke


On Monday 05 October 2009 07:24:37 pm Miguel Mitrofanov wrote:
> And I agree that sometimes it can be suitable.
> 
> But simply "defining an instance of Num" without a single word on the
> problem one
> is trying to solve is not just pointless. It's something that should
> not be done.
> >
> > On Mon, Oct 5, 2009 at 6:46 PM, Miguel Mitrofanov <miguelim...@yandex.ru
> >
> > > wrote:
> > >
> >>> "Just pairs" have no natural arithmetic upon them.
> >>
> >> Exactly my point.
> >>
> >>> BTW. the missing term of M.M. is DUAL NUMBERS.
> >>
> >> Remembered this already. Thanks anyway.
> >>
> >> _______________________________________________
> >> Haskell-Cafe mailing list
> >> Haskell-Cafe@haskell.org
> >> http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe@haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to